September 2018
Intermediate to advanced
328 pages
9h 10m
English
The second section contains functions that manage transactions in the Wasm instance (through the WasmTransactions instance) and the API, as follows:
... getCategories() { const categories = this.state.transactions.map( ({ category }) => category ); // Remove duplicate categories and sort the names in ascending order: return _.uniq(categories).sort(); }, // Populate global state with the transactions from the API response: populateTransactions(transactions) { const sortedTransactions = _.sortBy(transactions, [ 'transactionDate', 'id' ]); this.state.transactions = sortedTransactions; store.wasm.populateInWasm(sortedTransactions, this.getCategories()); this.recalculateBalances(); }, addTransaction(newTransaction) { // ...Read now
Unlock full access