Created
March 13, 2018 18:27
-
-
Save bowheart/40eb0600dc25cb17e723150a2f005846 to your computer and use it in GitHub Desktop.
A simple ticking clock example with React, RxJS, and React Zedux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import { Observable } from 'rxjs' | |
import { createContext } from 'react-zedux' | |
const tick$ = Observable.interval(1000) | |
const TickContext = createContext(tick$) | |
const App = () => ( | |
<TickContext.Provider> | |
<Clock /> | |
</TickContext.Provider> | |
) | |
const Clock = () => ( | |
<TickContext.Consumer> | |
{() => new Date().toTimeString()} | |
</TickContext.Consumer> | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment