single-source.subscribe(path, callback)
const createStore = require('single-source').createStore;
const CURRENT_LANG = 'currentLanguage';
const initialState = {
items: [],
currentLanguage: 'en',
};
const myStore = createStore(initialState);
myStore.subscribe(CURRENT_LANG, (newLanguage) => {
console.log('the new Language is: ', newLanguage);
})
myStore.dispatch({
path: CURRENT_LANG,
payload: 'fr',
});
no comments