From 17c9b3e1be47140e47867452a3721aa79a0545db Mon Sep 17 00:00:00 2001 From: Tomas Weiss Date: Sat, 13 Feb 2016 22:44:55 +0100 Subject: [PATCH] initial poc --- .gitignore | 1 + package.json | 11 +++++++++++ src/main.js | 15 +++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 .gitignore create mode 100644 package.json create mode 100644 src/main.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..377ae25 --- /dev/null +++ b/package.json @@ -0,0 +1,11 @@ +{ + "name": "redux-saga-rxjs", + "version": "0.1.0", + "description": "Saga pattern for Redux implemented using rxjs", + "main": "index.js", + "author": "Tomas Weiss ", + "license": "MIT", + "peerDependencies": { + "rxjs": "^5.0.0-beta.2" + } +} diff --git a/src/main.js b/src/main.js new file mode 100644 index 0000000..7cf251a --- /dev/null +++ b/src/main.js @@ -0,0 +1,15 @@ +import { Subject } from 'rxjs'; + +const sagaMiddleware = (...sagas) => { + const subject = new Subject(); + + return store => { + sagas.forEach(saga => + saga(subject).subscribe(dispatchable => store.dispatch(dispatchable)); + + return next => action => { + next(action); + subject.next(action, store.getState()); + }; + }; +};