Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md #17

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ It accepts a list of the modules.
Each module is just a function, which will accept a store and bind their event listeners.

```js
import wixWindow from 'wix-window';
import { query } from 'wix-location-frontend';
import { createStoreon } from 'storeon-velo';

// Business logic
Expand All @@ -192,25 +192,35 @@ const appModule = (store) => {
};

// Devtools
const logger = (store) => {
export const logger = (store) => {
store.on('@dispatch', (state, [event, data]) => {
if (event === '@changed') {
const keys = Object.keys(data).join(', ');
console.log('changed:', keys, state);
} else if (typeof data !== 'undefined') {
console.log('action:', event, data);
console.info(
`%c @changed:%c ${Object.keys(data).join(', ')}\n`,
'color:#25a55a;font-weight:bold;',
'font-style:oblique;',
state,
);
} else {
console.log('action:', event);
console.info(
`%c action:%c ${event}`,
'color:#c161f0;font-weight:bold;',
'color:#f69891;',
typeof data !== 'undefined' ? data : '',
);
}
});
};

const { getState, setState, dispatch, connect, readyStore } = createStoreon([
appModule,
wixWindow.viewMode === 'Preview' && logger,
// Enable development logger if a query param in the URL is ?logger=on
query.logger === 'on' && logger,
]);

$w.onReady(readyStore);
$w.onReady(() => {
return readyStore();
});
```

Syntax
Expand Down