Skip to content

Commit

Permalink
Tiny changes
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanmak committed Jul 27, 2015
1 parent 884cf09 commit 8c49998
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 3 additions & 2 deletions flux-by-rx/src/actions/todo.ts
Expand Up @@ -14,13 +14,14 @@ export let todoRemoved = (idx: number) => {
export class AddTodo implements Action {
constructor(private text: string) {}

value () { return this.text; }
update(state: TodoState) {
let value = this.text;
return assign({}, state, { todos: state.todos.push(value) });
return assign({}, state, { todos: state.todos.push(this.value()) });
}

toString() {
return JSON.stringify({ Add: this.text });
return JSON.stringify({ Add: this.value() });
}
}

Expand Down
8 changes: 6 additions & 2 deletions flux-by-rx/src/main.ts
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import { action$, Action } from './action';
import { ClearActions } from './actions/clearActions';
import * as Rx from 'rx';
import { Observable, ReplaySubject } from 'rx';
import { Observable } from 'rx';
import { model, initialState } from './model';
import view from './view';

Expand All @@ -25,7 +25,11 @@ function run() {
let state$ = model(replay$, initialState);

let playback$ = replay$.scan([], (actions, a) => {
return (a instanceof ClearActions) ? [] : <Action []>[...actions, a]
if (a instanceof ClearActions) {
return [];
}
console.log('Playback', a.toString());
return <Action[]>[...actions, a]
});

let output$ = view(state$, playback$);
Expand Down

0 comments on commit 8c49998

Please sign in to comment.