Skip to content

Instantly share code, notes, and snippets.

@bowheart
Created March 13, 2018 18:27
Show Gist options
  • Save bowheart/40eb0600dc25cb17e723150a2f005846 to your computer and use it in GitHub Desktop.
Save bowheart/40eb0600dc25cb17e723150a2f005846 to your computer and use it in GitHub Desktop.
A simple ticking clock example with React, RxJS, and React Zedux
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