Last active
November 24, 2019 16:15
-
-
Save VinixGonzalez/5110f54aa413df2775f48f765bc7cd35 to your computer and use it in GitHub Desktop.
Mobx RootStore do exemplo
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
import { observable, action, computed } from 'mobx'; | |
class RootStore { | |
@observable usuarioLogado = 'Vinicius Gonzalez'; | |
@observable listaUsuarios = []; | |
@action addUsuario = (usuario) => { | |
this.listaUsuarios.push(usuario); | |
} | |
@computed get totalUsuarios() { | |
return this.usersList.length; | |
} | |
} | |
export default new RootStore(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment