File tree 2 files changed +6
-9
lines changed
2 files changed +6
-9
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ const defaultOptions = {
64
64
customDispatch : getDelayedDispatch ,
65
65
isGossipType : isGossipType ,
66
66
verifyAsync : undefined ,
67
+ signAsync : undefined ,
67
68
}
68
69
69
70
export default class Dispatcher extends Scuttlebutt {
@@ -78,6 +79,7 @@ export default class Dispatcher extends Scuttlebutt {
78
79
this . _isGossipType = this . options . isGossipType
79
80
80
81
this . _verifyAsync = this . options . verifyAsync
82
+ this . _signAsync = this . options . signAsync
81
83
82
84
// redux methods to wrap
83
85
this . _reduxDispatch = ( ) => {
@@ -190,14 +192,9 @@ export default class Dispatcher extends Scuttlebutt {
190
192
// we should ensure we don't send objects which will explode JSON.parse here
191
193
// implemented over scuttlebutt class
192
194
localUpdate ( action ) {
193
- if ( process . env . NODE_ENV === 'development' ) {
194
- try {
195
- super . localUpdate ( action )
196
- } catch ( error ) {
197
- throw new Error ( 'Scuttlebutt couldn\'t dispatch' , error )
198
- }
195
+ if ( this . _signAsync ) {
196
+ this . _signAsync ( super . localUpdate . bind ( this ) , action , this . _reduxGetState )
199
197
} else {
200
- // try our luck
201
198
super . localUpdate ( action )
202
199
}
203
200
}
Original file line number Diff line number Diff line change @@ -150,11 +150,11 @@ tape('dispatcher({ signAsync })', function (t) {
150
150
151
151
// first call
152
152
t . equal ( dispatch . getCall ( 0 ) . args [ 0 ] . payload , payloads [ 0 ] , 'called dispatch with valid action 1' )
153
- t . equal ( dispatch . getCall ( 0 ) . args [ 0 ] . signed , payloads [ 0 ] , 'called dispatch with signed action 1' )
153
+ t . ok ( dispatch . getCall ( 0 ) . args [ 0 ] . signed , 'called dispatch with signed action 1' )
154
154
155
155
// second call
156
156
t . equal ( dispatch . getCall ( 1 ) . args [ 0 ] . payload , payloads [ 1 ] , 'called dispatch with valid action 2' )
157
- t . equal ( dispatch . getCall ( 1 ) . args [ 0 ] . signed , payloads [ 0 ] , 'called dispatch with signed action 2' )
157
+ t . ok ( dispatch . getCall ( 1 ) . args [ 0 ] . signed , 'called dispatch with signed action 2' )
158
158
159
159
t . equal ( getState . callCount , 2 , 'getState was called for each getHistory' )
160
160
t . end ( )
You can’t perform that action at this time.
0 commit comments