This file contains hidden or 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
| /* | |
| As vezes queremos executar uma ação após um insert, update e delete no firestore. | |
| Por exemplo após inserir um registro ou documento querer indexar no algolia, | |
| elasticsearch para consultas full text search, ou querer executar algum job/work | |
| para uma ação específica. | |
| As triggers onCreate, onWrite, onUpdate, onDelete possibilita vc executar qq ação | |
| após a execução de create, write, update ou delete no firestore. | |
| No exemplo abaixo sempre que algum post for adicionado as funções serão chamadas |
This file contains hidden or 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
| const execute = async (params) => { | |
| return new Promise((resolve,reject)=>{ | |
| try{ | |
| if(params===true) throw "Erro" //força exception | |
| resolve(params) | |
| }catch(e){ | |
| reject(e) | |
| } | |
| }) | |
| } |
This file contains hidden or 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
| export const soma = (x,y) => { | |
| return x+y | |
| } | |
| export const multiplica = (x,y)=>{ | |
| return x*y | |
| } | |
| export const subtrai = (x,y)=>{ | |
| return x-y |
This file contains hidden or 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
| const callback = () => { | |
| console.log('executou callback') | |
| } | |
| const exec = async (cb) => { | |
| console.log('exec começo') | |
| cb() | |
| console.log('exec fim') | |
| } |
This file contains hidden or 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
| class Abstrata { | |
| print = () => { | |
| throw "método abstrato precisa de implementação" | |
| } | |
| } | |
| class Concreta1 extends Abstrata { | |
| print = () => { | |
| console.log('Classe concreta1 que estende classe abstrata') | |
| } |
This file contains hidden or 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
| const {hello,espaco,world,helloworld} = require('./modulos') | |
| const test = () => { | |
| console.log(`${hello()}${espaco()}${world()}`) | |
| console.log(`${helloworld()}`) | |
| } | |
| (async ()=>{test()})() |
This file contains hidden or 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
| const {funcao1,funcao2,funcao3} = require('./modules') | |
| exports.test = test = async () => { | |
| await funcao1() | |
| await funcao2() | |
| await funcao3() | |
| } | |
| (async ()=>{ test() })() //chama test |
This file contains hidden or 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
| /* | |
| Compilar: gcc -o hello hello.c | |
| Executar: ./hello | |
| */ | |
| #include <stdio.h> | |
| int main() { | |
| printf("Hello World\n"); | |
| return 0; | |
| } |
This file contains hidden or 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
| /* | |
| Compilar: gcc -o array array.c | |
| Executar: ./array | |
| */ | |
| #include <stdio.h> | |
| void preencheArray(int* array){ | |
| for(int i=0;i<5;i++){ | |
| array[i] = i+1; | |
| } |
This file contains hidden or 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
| /* | |
| Compilar: gcc -o copy copy.c | |
| Executar: ./copy | |
| */ | |
| #import <stdio.h> | |
| void naoAlteraValor(int x){ | |
| x=0; | |
| } |