File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed
Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -156,6 +156,15 @@ export class Overmind<Config extends Configuration> implements BaseApp {
156156 } else {
157157 this . initialized = Promise . resolve ( null )
158158 }
159+
160+ if ( IS_PRODUCTION ) {
161+ let nextTick
162+ const flushTree = ( ) => proxyStateTree . flush ( )
163+ this . proxyStateTree . addMutationListener ( ( ) => {
164+ clearTimeout ( nextTick )
165+ nextTick = setTimeout ( flushTree , 0 )
166+ } )
167+ }
159168 }
160169 private createExecution ( name , action ) {
161170 return {
@@ -204,9 +213,7 @@ export class Overmind<Config extends Configuration> implements BaseApp {
204213 private createAction ( name , action ) {
205214 this . actionReferences . push ( action )
206215 return ( value ?) => {
207- if ( IS_PRODUCTION ) {
208- return action ( value )
209- } else if ( action [ IS_PIPE ] ) {
216+ if ( IS_PRODUCTION || action [ IS_PIPE ] ) {
210217 return new Promise ( ( resolve , reject ) => {
211218 const execution = this . createExecution ( name , action )
212219 this . eventHub . emit ( EventType . ACTION_START , execution )
Original file line number Diff line number Diff line change 11const isPlainObject = require ( 'is-plain-object' )
2- const IS_PRODUCTION = process . env . NODE_ENV === 'production'
32
43export const IS_PROXY = Symbol ( 'IS_PROXY' )
54export const PATH = Symbol ( 'PATH' )
@@ -30,7 +29,7 @@ function shouldTrackMutations(tree, path) {
3029}
3130
3231function ensureMutationTrackingIsEnabled ( tree , path ) {
33- if ( ! tree . status . has ( STATUS . TRACKING_MUTATIONS ) ) {
32+ if ( tree . options . devmode && ! tree . status . has ( STATUS . TRACKING_MUTATIONS ) ) {
3433 throw new Error (
3534 `proxy-state-tree - You are mutating the path "${ path } ", but it is not allowed`
3635 )
You can’t perform that action at this time.
0 commit comments