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
class SearchStore { | |
@observable searchText; | |
@action | |
setSearchText = (searchText) => { | |
this.searchText = searchText | |
} | |
} | |
@observer |
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
const searchStore = new SearchStore(); | |
const app = ( | |
<Provider searchStore={searchStore}> | |
<SearchInput /> | |
</Provider> | |
); | |
ReactDom.render(app, container); |
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
class TodoApi { | |
fetchTodos = () => request.get('/todos') | |
} | |
class TodoStore { | |
@observable todos = []; | |
constructor(todoApi) { |
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
const hiddenSymbol = Symbol(); | |
const obj = { a: 1 }; | |
obj[hiddenSymbol] = 'hidden'; | |
// print all keys | |
const keys = Object.keys(obj); | |
console.log(keys); // prints ['a'] | |
// print value of prop hiddenSymbol | |
console.log(obj[hiddenSymbol]); // prints 'hidden' |
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
class MyStore { | |
@observable.ref deviceStatus; // Device status is sth. like { isConnected, etc. } | |
@action | |
updateStatus = (deviceStatus) => { | |
this.deviceStatus = deviceStatus; | |
} | |
}; | |
const store = new MyStore(); |
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
'use strict'; | |
const fs = require('fs'); | |
const path = require('path'); | |
const HtmlWebpackPlugin = require('html-webpack-plugin'); | |
const webpack = require('webpack'); | |
const config = { | |
mode: 'development', | |
entry: [ | |
'webpack/hot/dev-server', |