Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Odonno/react-rxjs-spy-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-rxjs-spy-example

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");

About

An example that demonstrate how to use rxjs-spy to debug observables inside a react/rxjs application

Topics

Resources

Stars

Watchers

Forks