Created
October 28, 2016 06:57
-
-
Save janneh/2babab55d5257ecc1fb18e2eddcdac29 to your computer and use it in GitHub Desktop.
Base playing around with testing redux-observable
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="https://unpkg.com/redux@^3.5.2/dist/redux.min.js"></script> | |
<script src="https://unpkg.com/@reactivex/[email protected]/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> |
This file contains hidden or 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
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