@@ -83,7 +83,7 @@ def get_state():
83
83
* @param {Function} listener A callback to be invoked on every dispatch.
84
84
* @returns {Function} A function to remove this change listener.
85
85
"""
86
- def subscribe (listener ):
86
+ def subscribe (listener = None ):
87
87
nonlocal next_listeners
88
88
if not hasattr (listener , '__call__' ):
89
89
raise Exception ('Expected listener to be a function' )
@@ -128,12 +128,12 @@ def unsubscribe():
128
128
* Note that, if you use a custom middleware, it may wrap `dispatch()` to
129
129
* return something else (for example, a Promise you can await).
130
130
"""
131
- def dispatch (action ):
131
+ def dispatch (action = None ):
132
132
nonlocal is_dispatching , current_state , current_listeners , next_listeners
133
133
if not type (action ) == dict :
134
134
raise Exception ('Actions must be plain dictionaries. Consider adding middleware to change this' )
135
- if not action .get ('type' ):
136
- raise Exception ('Actions may not have have an undefined "type" property.\n Have you misspelled a constants?' )
135
+ if action .get ('type' ) is None :
136
+ raise Exception ('Actions may not have an undefined "type" property.\n Have you misspelled a constants?' )
137
137
if is_dispatching :
138
138
raise Exception ('Reducers may not dispatch actions' )
139
139
@@ -158,16 +158,14 @@ def dispatch(action):
158
158
* @param {Function} nextReducer The reducer for the store to use instead.
159
159
* @returns {void}
160
160
"""
161
- def replace_reducer (next_reducer ):
161
+ def replace_reducer (next_reducer = None ):
162
162
nonlocal current_reducer
163
163
if not hasattr (next_reducer , '__call__' ):
164
164
raise Exception ('Expected next_reducer to be a function' )
165
165
current_reducer = next_reducer
166
166
dispatch ({ 'type' : ACTION_TYPES ['INIT' ] })
167
167
168
- """
169
- TODO: Figure out how to add the observables
170
- """
168
+ # TODO: Figure out how to add the observables
171
169
172
170
# When a store is created, an "INIT" action is dispatched so that every
173
171
# reducer returns their initial state. This effectively populates
0 commit comments