def go(): initial_state = { 'todos': (), } store = yield from aioredux.create_store(lambda state, action: state, initial_state, loop=self.loop) self.assertIsNotNone(store) self.assertIsNotNone(store.state)
def go(): initial_state = { 'todos': (), } store = yield from aioredux.create_store(lambda state, action: state, initial_state, loop=self.loop) self.assertEqual(len(store.listeners), 0) unsubscribe = store.subscribe(lambda: None) self.assertEqual(len(store.listeners), 1) unsubscribe() self.assertEqual(len(store.listeners), 0)
def go(): initial_state = { 'todos': (), } def add_todo(text): return {'type': 'ADD_TODO', 'text': text} def reducer(state, action): if action['type'] == 'ADD_TODO': todos = state['todos'] + (action['text'],) return toolz.assoc(state, 'todos', todos) return state store = yield from aioredux.create_store(reducer, initial_state, loop=self.loop) self.assertIsNotNone(store.state) self.assertIsNotNone(store.state['todos']) self.assertEqual(len(store.state['todos']), 0) yield from store.dispatch(add_todo('todo text')) self.assertIsNotNone(store.state) self.assertIsNotNone(store.state['todos']) self.assertEqual(len(store.state['todos']), 1)