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
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 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
/* | |
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 set = new Set([1,1,2,2,3,3,4,4,5,5]) | |
const array = Array.from(set) | |
console.log(array) //(5) [1, 2, 3, 4, 5] |
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
/* | |
yarn add express body-parser cors | |
node index.js | |
*/ | |
const express = require('express') | |
const bodyParser = require('body-parser') | |
const app = express() | |
const cors = require('cors'); |
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
/* | |
1. require redis wrapper para executar open/close da conexão | |
2. Setar sua conexão redis na URL, use uma ENV do seu servidor | |
para não armazenar usuário/senha hardcoded. | |
*/ | |
const {redis} = require('./redis') | |
redis(async (client)=>{ | |
return Promise.all([ |
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
/* | |
Esse é o entry point default do react-native App.js. Ele contém um AuthProvider que detecta sempre | |
que o usuário estiver logado/deslogado para exibir a view correta. Views contém as views do usuário | |
logado/deslogado. | |
*/ | |
import React from 'react' | |
import {AuthProvider} from './AuthCtx' | |
import Views from './Views.js' |
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
/* | |
Those imports are to react-native-firebase and firebase storage. | |
If you use other client stuff, you must to replace the imports | |
by the include/imports of your languange | |
or framework, as well as the respective calls. | |
*/ | |
// START ---- | |
import firebase from '@react-native-firebase/app' |
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
Views.js | |
````` | |
import React from 'react' | |
import { NavigationContainer } from '@react-navigation/native' | |
import { createNativeStackNavigator } from '@react-navigation/native-stack' | |
const Stack = createNativeStackNavigator(); | |
const options = (route,params) => { |