Skip to content

Commit ab176a1

Browse files
feat(overmind-angular): add custom connect
1 parent f31c615 commit ab176a1

File tree

1 file changed

+19
-1
lines changed
  • packages/node_modules/overmind-angular/src

1 file changed

+19
-1
lines changed

packages/node_modules/overmind-angular/src/index.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@ export interface IConnect<Config extends Configuration> {
1313

1414
let nextComponentId = 0
1515

16-
export const createConnect = <A extends Overmind<any>>(overmind: A) => () => {
16+
export const createConnect = <A extends Overmind<any>>(overmind: A) => (
17+
propsCallback?: (
18+
overmind: {
19+
state: A['state']
20+
actions: A['actions']
21+
effects: A['effects']
22+
}
23+
) => object
24+
) => {
1725
const componentId = nextComponentId++
1826
let componentInstanceId = 0
1927

@@ -35,6 +43,16 @@ export const createConnect = <A extends Overmind<any>>(overmind: A) => () => {
3543
effects: overmind.effects,
3644
addMutationListener: overmind.addMutationListener,
3745
}
46+
if (propsCallback) {
47+
Object.assign(
48+
this,
49+
propsCallback({
50+
state: this.__tree.state,
51+
actions: overmind.actions,
52+
effects: overmind.effects,
53+
})
54+
)
55+
}
3856
this.__shouldUpdatePaths = false
3957
this.__componentInstanceId = componentInstanceId++
4058
this.__onUpdate = (mutations, paths, flushId) => {

0 commit comments

Comments
 (0)