Skip to content

Commit

Permalink
state updates are now being part of output
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejzasada committed Jul 3, 2017
1 parent 02cf38f commit 6a1dc44
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions lib/flowchat.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class Flowchat {
this.setInput(new Subject());
this._state = new Subject();
this._output = new Subject();
this._memStore = {};
this._activators = [];
this._paths = [];
this._reducers = {};
Expand All @@ -41,7 +42,8 @@ export class Flowchat {

// Send.
this._sendSaga = function* sendSaga({ data, sessionId }) {
yield self._send(data, sessionId);
const state = self._memStore[sessionId];
yield self._send(data, state, sessionId);
}
this._sendSagaRunner = function* sendSagaRunner() {
yield takeEvery('send', self._sendSaga);
Expand Down Expand Up @@ -224,6 +226,7 @@ export class Flowchat {

_run(flow, data, state, sessionId) {
const newState = this._reduce(flow, data, state, sessionId);
this._memStore[sessionId] = newState;
const runNext = () => {
this._store.dispatch({ type: flow, data, state: newState, sessionId });
}
Expand All @@ -247,8 +250,8 @@ export class Flowchat {
return state;
}

_send(data, sessionId) {
this._output.onNext({ data, sessionId });
_send(data, state, sessionId) {
this._output.onNext({ data, state, sessionId });
}

}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "flowchat",
"description": "Modern ES6 reactive framework for building scalable, maintainable and testable chat bots",
"version": "0.2.4",
"version": "0.3.2",
"author": "Maciej Zasada <hello@maciejzasada.com>",
"keywords": [
"flowchat",
Expand Down

0 comments on commit 6a1dc44

Please sign in to comment.