forked from cerebral/overmind
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservice.ts
More file actions
23 lines (22 loc) · 816 Bytes
/
service.ts
File metadata and controls
23 lines (22 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// @ts-ignore
import { Injectable } from '@angular/core'
import { IConfiguration, Overmind } from 'overmind'
@Injectable()
export class OvermindService<Config extends IConfiguration> {
private overmind: any
actions: Overmind<Config>['actions']
effects: Overmind<Config>['effects']
addMutationListener: Overmind<Config>['addMutationListener']
reaction: Overmind<Config>['reaction']
constructor(overmind: Overmind<Config>) {
this.overmind = overmind
this.actions = this.overmind.actions
this.addMutationListener = this.overmind.addMutationListener
this.reaction = this.overmind.reaction
}
select<T>(expr: (state: Overmind<Config>['state']) => T): T
select(): Overmind<Config>['state']
select(...args) {
return args[0] ? args[0](this.overmind.state) : this.overmind.state
}
}