Skip to content

Commit e8d6023

Browse files
Merge pull request cerebral#86 from cerebral/improvements
Improvements
2 parents ff82571 + 0860819 commit e8d6023

File tree

6 files changed

+110
-104
lines changed

6 files changed

+110
-104
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ export default class VueApp<
9696
// a callback that runs whenever a mutation
9797
// matches the paths tracked on this component
9898
componentOptions.mounted = function() {
99-
const vueInstance = this
100-
const paths = instance.clearTrackState(this.__trackId, () => {
101-
mounted && mounted.call(vueInstance)
102-
})
99+
const paths = instance.clearTrackState(
100+
this.__trackId,
101+
mounted && mounted.bind(this)
102+
)
103103
instance.eventHub.emitAsync(EventType.COMPONENT_ADD, {
104104
componentId,
105105
componentInstanceId: this.__componentInstanceId,

packages/node_modules/overmind/src/computed.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { EventEmitter } from 'betsy'
22
import ProxyStateTree from 'proxy-state-tree'
3-
import { Events, EventType } from './'
3+
import { Events, EventType } from './internalTypes'
44

55
type ComputedOptions = {
66
cacheLimit?: number

packages/node_modules/overmind/src/derived.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { EventEmitter } from 'betsy'
22
import ProxyStateTree from 'proxy-state-tree'
3-
import { Events, EventType } from './'
3+
import { Events, EventType } from './internalTypes'
44

55
class Derived {
66
private isDirty: boolean = true

packages/node_modules/overmind/src/index.ts

Lines changed: 8 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,17 @@ import ProxyStateTree from 'proxy-state-tree'
44
import Devtools, { Message, safeValue } from './Devtools'
55
import ActionClass, { IValueAction, INoValueAction, Compose } from './Action'
66
import Reaction from './reaction'
7+
import {
8+
DynamicModule,
9+
SubType,
10+
Events,
11+
EventType,
12+
Options,
13+
} from './internalTypes'
714
export { default as derive } from './derived'
815
export { default as compute } from './computed'
916

10-
export { IValueAction, Compose }
17+
export { IValueAction, Compose, EventType }
1118

1219
export const log = (...objects: any[]) =>
1320
console.log(...objects.map((obj) => JSON.parse(JSON.stringify(obj))))
@@ -18,18 +25,6 @@ export const dynamicModule = ((cb) => (namespace) =>
1825
/*
1926
BASE TYPES
2027
*/
21-
type DynamicModule = <
22-
T extends {
23-
onInitialize?: any
24-
state?: any
25-
effects?: any
26-
actions?: any
27-
reactions?: any
28-
}
29-
>(
30-
cb: (namespace: string) => T
31-
) => ReturnType<typeof cb>
32-
3328
export type Configuration = {
3429
onInitialize?: any
3530
state?: any
@@ -47,11 +42,6 @@ export type Configuration = {
4742
}
4843
}
4944

50-
type SubType<Base, Condition> = Pick<
51-
Base,
52-
{ [Key in keyof Base]: Base[Key] extends Condition ? Key : never }[keyof Base]
53-
>
54-
5545
/*
5646
DECLARE MODULE TYPES
5747
*/
@@ -267,85 +257,6 @@ export type TCompute<Value, App> = (
267257
CLASS TYPES
268258
*/
269259

270-
type Options = {
271-
devtools?: string
272-
}
273-
274-
type CacheMessage = {
275-
value: any
276-
paths: string[]
277-
updateCount: number
278-
}
279-
280-
export enum EventType {
281-
DERIVED = 'derived',
282-
DERIVED_DIRTY = 'derived:dirty',
283-
COMPUTED = 'computed',
284-
COMPUTED_DIRTY = 'computed:dirty',
285-
REACTION_ADD = 'reaction:add',
286-
REACTION_UPDATE = 'reaction:update',
287-
REACTION_REMOVE = 'reaction:remove',
288-
COMPONENT_ADD = 'component:add',
289-
COMPONENT_UPDATE = 'component:update',
290-
COMPONENT_REMOVE = 'component:remove',
291-
}
292-
293-
export interface Events {
294-
[EventType.DERIVED]: {
295-
path: string
296-
paths: string[]
297-
updateCount: number
298-
value: any
299-
}
300-
[EventType.DERIVED_DIRTY]: {
301-
path: string
302-
flushId: number
303-
}
304-
[EventType.COMPUTED]: {
305-
path: string
306-
updateCount: number
307-
cache: CacheMessage[]
308-
limit: number
309-
}
310-
[EventType.COMPUTED_DIRTY]: {
311-
path: string
312-
flushId: number
313-
}
314-
[EventType.REACTION_ADD]: {
315-
path: string
316-
statePath: string
317-
updateCount: number
318-
}
319-
[EventType.REACTION_UPDATE]: {
320-
path: string
321-
statePath: string
322-
updateCount: number
323-
}
324-
[EventType.REACTION_REMOVE]: {
325-
path: string
326-
statePath: string
327-
updateCount: number
328-
}
329-
[EventType.COMPONENT_ADD]: {
330-
componentId: number
331-
componentInstanceId: number
332-
name: string
333-
paths: string[]
334-
}
335-
[EventType.COMPONENT_UPDATE]: {
336-
componentId: number
337-
componentInstanceId: number
338-
name: string
339-
paths: string[]
340-
flushId?: number
341-
}
342-
[EventType.COMPONENT_REMOVE]: {
343-
componentId: number
344-
componentInstanceId: number
345-
name: string
346-
}
347-
}
348-
349260
export default class App<
350261
Config extends Configuration,
351262
EvalConfig extends TConfig<Config>
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
export type DynamicModule = <
2+
T extends {
3+
onInitialize?: any
4+
state?: any
5+
effects?: any
6+
actions?: any
7+
reactions?: any
8+
}
9+
>(
10+
cb: (namespace: string) => T
11+
) => ReturnType<typeof cb>
12+
13+
export type SubType<Base, Condition> = Pick<
14+
Base,
15+
{ [Key in keyof Base]: Base[Key] extends Condition ? Key : never }[keyof Base]
16+
>
17+
18+
export type Options = {
19+
devtools?: string
20+
}
21+
22+
type CacheMessage = {
23+
value: any
24+
paths: string[]
25+
updateCount: number
26+
}
27+
28+
export enum EventType {
29+
DERIVED = 'derived',
30+
DERIVED_DIRTY = 'derived:dirty',
31+
COMPUTED = 'computed',
32+
COMPUTED_DIRTY = 'computed:dirty',
33+
REACTION_ADD = 'reaction:add',
34+
REACTION_UPDATE = 'reaction:update',
35+
REACTION_REMOVE = 'reaction:remove',
36+
COMPONENT_ADD = 'component:add',
37+
COMPONENT_UPDATE = 'component:update',
38+
COMPONENT_REMOVE = 'component:remove',
39+
}
40+
41+
export interface Events {
42+
[EventType.DERIVED]: {
43+
path: string
44+
paths: string[]
45+
updateCount: number
46+
value: any
47+
}
48+
[EventType.DERIVED_DIRTY]: {
49+
path: string
50+
flushId: number
51+
}
52+
[EventType.COMPUTED]: {
53+
path: string
54+
updateCount: number
55+
cache: CacheMessage[]
56+
limit: number
57+
}
58+
[EventType.COMPUTED_DIRTY]: {
59+
path: string
60+
flushId: number
61+
}
62+
[EventType.REACTION_ADD]: {
63+
path: string
64+
statePath: string
65+
updateCount: number
66+
}
67+
[EventType.REACTION_UPDATE]: {
68+
path: string
69+
statePath: string
70+
updateCount: number
71+
}
72+
[EventType.REACTION_REMOVE]: {
73+
path: string
74+
statePath: string
75+
updateCount: number
76+
}
77+
[EventType.COMPONENT_ADD]: {
78+
componentId: number
79+
componentInstanceId: number
80+
name: string
81+
paths: string[]
82+
}
83+
[EventType.COMPONENT_UPDATE]: {
84+
componentId: number
85+
componentInstanceId: number
86+
name: string
87+
paths: string[]
88+
flushId?: number
89+
}
90+
[EventType.COMPONENT_REMOVE]: {
91+
componentId: number
92+
componentInstanceId: number
93+
name: string
94+
}
95+
}

packages/node_modules/overmind/src/reaction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { EventEmitter } from 'betsy'
22
import ProxyStateTree from 'proxy-state-tree'
3-
import { Events, EventType } from './'
3+
import { Events, EventType } from './internalTypes'
44

55
class Reaction {
66
private proxyStateTreeListener: any = null

0 commit comments

Comments
 (0)