File tree Expand file tree Collapse file tree 3 files changed +26
-10
lines changed
Expand file tree Collapse file tree 3 files changed +26
-10
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,7 @@ export class Component {
9898 name : this . name ,
9999 paths : Array . from ( paths ) ,
100100 } )
101+
101102 this . vtree . mount ( this , this . context )
102103 for ( const listener of this . mountListeners ) {
103104 listener ( )
Original file line number Diff line number Diff line change @@ -6,11 +6,21 @@ export function useOvermind<Config extends IConfig>(): {
66 actions : TApp < Config > [ 'actions' ]
77} {
88 const component = Component . current
9+ const existingHook = component . getHook ( )
10+
11+ if ( existingHook ) {
12+ component . nextHookIndex ++
13+ return existingHook
14+ }
915
10- return {
16+ const hook = {
1117 state : component . context . app . state ,
1218 actions : component . context . app . actions ,
1319 }
20+
21+ component . addHook ( hook )
22+
23+ return hook
1424}
1525
1626export function useState < T > ( initialState : T ) : [ T , ( update : T ) => void ] {
Original file line number Diff line number Diff line change @@ -89,6 +89,7 @@ export class Overmind<Config extends Configuration> implements Configuration {
8989 the eventHub
9090 */
9191 const proxyStateTree = new ProxyStateTree ( this . getState ( configuration ) , {
92+ devmode : ! IS_PRODUCTION ,
9293 dynamicWrapper : ( proxyStateTree , path , func ) =>
9394 func ( eventHub , proxyStateTree , path ) ,
9495 } )
@@ -218,15 +219,19 @@ export class Overmind<Config extends Configuration> implements Configuration {
218219 const execution = this . createExecution ( name , action )
219220 this . eventHub . emit ( EventType . ACTION_START , execution )
220221
221- action (
222- null ,
223- this . createContext ( value , execution , this . proxyStateTree . get ( ) ) ,
224- ( err , val ) => {
225- this . eventHub . emit ( EventType . ACTION_END , execution )
226- if ( err ) reject ( err )
227- else resolve ( val )
228- }
229- )
222+ action [ IS_PIPE ]
223+ ? action (
224+ null ,
225+ this . createContext ( value , execution , this . proxyStateTree . get ( ) ) ,
226+ ( err , val ) => {
227+ this . eventHub . emit ( EventType . ACTION_END , execution )
228+ if ( err ) reject ( err )
229+ else resolve ( val )
230+ }
231+ )
232+ : action (
233+ this . createContext ( value , execution , this . proxyStateTree . get ( ) )
234+ )
230235 } )
231236 } else {
232237 const execution = {
You can’t perform that action at this time.
0 commit comments