The import and store declarations

The first section contains import statements and the wasm and state properties on the exported store object, as follows:

import {
apiFetchTransactions,
apiAddTransaction,
apiEditTransaction,
apiRemoveTransaction
} from './api.js';
import WasmTransactions from './WasmTransactions.js';

export const store = {
wasm: null,
state: {
transactions: [],
activeTransactionId: 0,
balances: {
initialRaw: 0,
currentRaw: 0,
initialCooked: 0,
currentCooked: 0
}
},
...

All API interaction is limited to the store.js file. Since we need to manipulate, add, and search transactions, all of the exported functions from api.js are imported. The store object holds the WasmTransactions instance in the wasm property and initial state in the state property. The values in state are referenced in multiple locations throughout the application. The store object will be added to the global window object when the application loads, so all components have access to the global state.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset