juliette
Version:
Reactive State Management Powered by RxJS
20 lines • 738 B
JavaScript
import { take, withLatestFrom } from 'rxjs/operators';
export const log = (store) => {
store.state$.pipe(take(1)).subscribe(logState);
store.handlers$.pipe(withLatestFrom(store.state$)).subscribe(([handler, state]) => {
logHandler(handler);
logState(state);
});
};
const loggingStyle = 'color: #0099A5; font:1em Comic Sans MS; font-weight: bold';
const logState = (state) => {
console.groupCollapsed('%c🪐 State:', loggingStyle);
Object.keys(state)
.sort()
.forEach(key => console.log(key, state[key]));
console.groupEnd();
};
const logHandler = (handler) => {
console.log(`%c🚀 Handler: ${handler.type}`, loggingStyle);
};
//# sourceMappingURL=log.js.map