Skip to content

Instantly share code, notes, and snippets.

@janneh
Created October 28, 2016 06:57
Show Gist options
  • Save janneh/2babab55d5257ecc1fb18e2eddcdac29 to your computer and use it in GitHub Desktop.
Save janneh/2babab55d5257ecc1fb18e2eddcdac29 to your computer and use it in GitHub Desktop.
Base playing around with testing redux-observable
<!DOCTYPE html>
<html>
<head>
<script src="https://unpkg.com/redux@^3.5.2/dist/redux.min.js"></script>
<script src="https://unpkg.com/@reactivex/rxjs@5.0.0-beta.12/dist/global/Rx.js"></script>
<script src="https://unpkg.com/redux-observable/dist/redux-observable.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<button id="trigger">Click to PING</button>
</body>
<script>
const { createStore, applyMiddleware } = Redux
const { createEpicMiddleware } = ReduxObservable
const epicMiddleware = createEpicMiddleware() // insert epics here
const store = createStore(pingReducer,
applyMiddleware(epicMiddleware)
)
const log = () => {
const state = store.getState()
console.log(state)
}
store.subscribe(log)
</script>
</html>
const button = document.getElementById("trigger")
const click$ = Rx.Observable.fromEvent(button, "click")
click$
.mapTo("hello world")
.subscribe(v => console.log(v))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment