File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed
packages/node_modules/overmind-vue/src Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,25 @@ describe('Vue', () => {
2121 )
2222 expect ( vm . overmind . state . foo ) . toBe ( 'bar' )
2323 } )
24+ it ( 'should mount with custom connected app' , ( ) => {
25+ const app = new Overmind ( {
26+ state : {
27+ foo : 'bar' ,
28+ } ,
29+ } )
30+ const connect = createConnect ( app )
31+ const vm = new Vue (
32+ connect (
33+ ( { state } ) => ( {
34+ state,
35+ } ) ,
36+ {
37+ el : dom . window . document . createElement ( 'div' ) ,
38+ }
39+ )
40+ )
41+ expect ( vm . state . foo ) . toBe ( 'bar' )
42+ } )
2443 it ( 'should expose actions' , ( done ) => {
2544 const app = new Overmind ( {
2645 state : {
Original file line number Diff line number Diff line change @@ -2,9 +2,11 @@ import { EventType } from 'overmind'
22
33let nextComponentId = 0
44
5- export const createConnect = ( overmind ) => ( options ) => {
5+ export const createConnect = ( overmind ) => ( ... args ) => {
66 const componentId = nextComponentId ++
77 let componentInstanceId = 0
8+ let options = args . length === 1 ? args [ 0 ] : args [ 1 ]
9+ let propsCallback = args . length === 1 ? null : args [ 0 ]
810
911 return {
1012 ...options ,
@@ -22,6 +24,16 @@ export const createConnect = (overmind) => (options) => {
2224 effects : overmind . effects ,
2325 addMutationListener : overmind . addMutationListener ,
2426 }
27+ if ( propsCallback ) {
28+ Object . assign (
29+ this ,
30+ propsCallback ( {
31+ state : this . __tree . state ,
32+ actions : overmind . actions ,
33+ effects : overmind . effects ,
34+ } )
35+ )
36+ }
2537 this . __tree . track ( this . __onUpdate )
2638 } ,
2739 beforeUpdate ( this : any ) {
You can’t perform that action at this time.
0 commit comments