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
import { createStore, applyMiddleware } from 'redux'; | |
//importa os middlewares | |
import logger from 'redux-logger'; | |
import thunk from 'redux-thunk'; | |
//importa os reducers | |
import rootReducers from './reducers'; | |
//cria a store passando os reducers e os middlewares | |
let store = createStore( | |
rootReducers, |
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
//exemplo estrutura de um middleware | |
export let middlewareExemplo = ({ getState, dispatch }) => next => action => { | |
//.next() passa a action para os proximos middlewares | |
//ate chegar nos reducers que atualizam o state | |
let result = next(action); | |
//retorna o retorno da execucao dos middlewares seguintes | |
//ou action caso seja o ultimo middleware em execucao | |
return result; | |
}; |
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
import CONSTANTS from '../constants/'; | |
const initialState = { | |
saldo: 0, | |
valorTransacao: 0, | |
erro: "" | |
}; | |
let reducerConta = (state = initialState, action) => { | |
switch (action.type) { |
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
import CONSTANTS from '../constants'; | |
export let actionCreditar = (valorCredito) => { | |
return { | |
type: CONSTANTS.CREDITO, | |
payload: { | |
valor: valorCredito | |
} | |
}; | |
}; |
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
//para modulos default | |
import variavelDefault from "./exemplo.js"; | |
//para modulos default que também possuem outros exports | |
import variavelDefault, { variavelNaoDefault } from "./exemplo.js"; | |
//renomeando a default | |
import { default as variavelDefault, variavelNaoDefault } from "./exemplo.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
export default function(a, b){ | |
return a+b; | |
} | |
//ou | |
function soma(a, b){ | |
return a + b; | |
} | |
export default soma; |
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
//importando apenas um identificador | |
import {algumaCoisa} from "./modulo-teste.js"; | |
//importando apenas um identificador e renomeando | |
import {algumaCoisa as teste} from "./modulo-teste.js"; | |
//importando vários identificadores | |
import {algumaCoisa, Pokemon, soma} from "./modulo-teste.js" | |
//importando o modulo inteiro |
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
//modulo-teste.js | |
//exportando variaveis | |
export var cor = "amarelo"; | |
export let nome = "Pikachu"; | |
export const peso = 20; | |
// exportando function | |
export function soma(num1, num2) { | |
return num1 + num1; |
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 Retangulo{ | |
constructor(largura, altura){ | |
//... | |
} | |
static métodoEstatico(){ | |
return "alguma coisa"; | |
} | |
}; | |
console.log(Retangulo.métodoEstatico());//"alguma coisa" |
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 Quadrado extends Retangulo { | |
// sem constructor | |
} | |
// é equivalente | |
class Quadrado extends Retangulo { | |
constructor(...parâmetros) { | |
super(...parâmetros); | |
} | |
} |
NewerOlder