Skip to content

Commit

Permalink
fix(overmind-vue): move last piece of logic over
Browse files Browse the repository at this point in the history
  • Loading branch information
christianalfoni committed Jan 23, 2021
1 parent 2652aa5 commit 4a694e7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
16 changes: 1 addition & 15 deletions packages/node_modules/overmind-vue/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
MODE_SSR,
Overmind,
} from 'overmind'
import { Component, ComponentOptions, defineComponent, provide, h } from 'vue'
import { Component, ComponentOptions } from 'vue'

type AnyComponent = ComponentOptions | Component

Expand Down Expand Up @@ -177,17 +177,3 @@ export function createConnect<Config extends IConfiguration>(
} as any
}
}

export const withOvermind = (
instance: Overmind<IConfiguration>,
Component: Component
) => {
return defineComponent({
setup() {
provide('overmind', instance)
},
render() {
return h(Component)
},
})
}
18 changes: 18 additions & 0 deletions packages/node_modules/overmind-vue/src/vue3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,30 @@ import {
onRenderTracked,
onMounted,
onBeforeUnmount,
defineComponent,
provide,
h,
Component,
} from 'vue'

const IS_PRODUCTION = ENVIRONMENT === 'production'

let nextComponentId = 0

export const withOvermind = (
instance: Overmind<IConfiguration>,
Component: Component
) => {
return defineComponent({
setup() {
provide('overmind', instance)
},
render() {
return h(Component)
},
})
}

export interface StateHook<Config extends IConfiguration> {
(): Ref<Overmind<Config>['state']>
<CB extends (state: Overmind<Config>['state']) => object>(
Expand Down

0 comments on commit 4a694e7

Please sign in to comment.