-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
175 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,23 @@ | ||
class Feature extends Nullstack { | ||
class WaifuCounter extends Nullstack { | ||
|
||
// runs in the server | ||
static async delete({ database }) { | ||
database.query("DELETE * FROM WAIFUS"); | ||
static async getWaifus({ database }) { | ||
const sql = "SELECT COUNT(*) FROM WAIFUS"; | ||
return database.query(sql); | ||
} | ||
|
||
// runs in the client | ||
async confirm() { | ||
if (confirm("You sure? uwu")) { | ||
await this.delete(); | ||
} | ||
async countWaifus() { | ||
this.waifus = this.getWaifus() | ||
} | ||
|
||
// runs wherever is best | ||
render() { | ||
return ( | ||
<button onclick={this.confirm}> | ||
Delete | ||
<button onclick={this.countWaifus}> | ||
Count: {this.waifus} | ||
</button> | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class WaifuCreator extends Nullstack { | ||
|
||
// extracted into a microservice | ||
static async insertWaifu({ database, name }) { | ||
const sql = "INSERT INTO waifus (name) VALUES (?)"; | ||
return database.query(sql, name); | ||
} | ||
|
||
// invokes the microservice | ||
async create() { | ||
this.insertWaifu({ name: "Nulla-Chan" }) | ||
} | ||
|
||
// render in the DOM | ||
render() { | ||
return ( | ||
<button onclick={this.create}> | ||
Create Waifu | ||
</button> | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,23 @@ | ||
class Feature extends Nullstack { | ||
class WaifuCounter extends Nullstack { | ||
|
||
// executa no servidor | ||
static async delete({ database }) { | ||
database.query("DELETE * FROM WAIFUS"); | ||
// roda no servidor | ||
static async getWaifus({ database }) { | ||
const sql = "SELECT COUNT(*) FROM WAIFUS"; | ||
return database.query(sql); | ||
} | ||
|
||
// executa no client | ||
async confirm() { | ||
if (confirm("Tem certeza? uwu")) { | ||
await this.delete(); | ||
} | ||
// roda no cliente | ||
async countWaifus() { | ||
this.waifus = this.getWaifus() | ||
} | ||
|
||
// executa onde for melhor | ||
// roda onde for melhor | ||
render() { | ||
return ( | ||
<button onclick={this.confirm}> | ||
Delete | ||
<button onclick={this.countWaifus}> | ||
Count: {this.waifus} | ||
</button> | ||
); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class WaifuCreator extends Nullstack { | ||
|
||
// extraído em um microsserviço | ||
static async insertWaifu({ database, name }) { | ||
const sql = "INSERT INTO waifus (name) VALUES (?)"; | ||
return database.query(sql, name); | ||
} | ||
|
||
// invoca o microsserviço | ||
async create() { | ||
this.insertWaifu({ name: "Nulla-Chan" }) | ||
} | ||
|
||
// renderiza no DOM | ||
render() { | ||
return ( | ||
<button onclick={this.create}> | ||
Criar Waifu | ||
</button> | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.