This repository is an example that demonstrate how to use rxjs-spy to debug observables inside a react/rxjs application.
First, let's create an observable.
const now$ = interval(1000).pipe(
map(_ => new Date()),
startWith(new Date()),
tag("now")
);
Then, create a react functional component using useObservable
hook.
const App = () => {
const now = useObservable<Date>(_ => now$);
return <div>{now && now.toLocaleString()}</div>;
}
And finally, add a spy on this observable which is linked by the tag
operator.
const spy = create();
spy.log("now");