forked from cerebral/overmind
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnect.ts
More file actions
66 lines (60 loc) · 1.62 KB
/
connect.ts
File metadata and controls
66 lines (60 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
export default () => [
{
fileName: 'overmind/index.ts',
code: `
import { IConfig } from 'overmind'
import { Injectable } from '@angular/core'
import { OvermindService } from 'overmind-angular'
import { state } from './state'
import * as actions from './actions'
export const config = { state, actions }
declare module 'overmind' {
interface Config extends IConfig<typeof config> {}
}
@Injectable()
export class Store extends OvermindService<typeof config> {}
`,
},
{
fileName: 'app.module.ts',
code: `
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { createOvermind } from 'overmind';
import { OvermindModule, OvermindService, OVERMIND_INSTANCE } from 'overmind-angular'
import { config, Store } from './overmind'
import { AppComponent } from './app.component';
@NgModule({
imports: [ BrowserModule, OvermindModule ],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ],
providers: [
{ provide: OVERMIND_INSTANCE, useValue: createOvermind(config) },
{ provide: Store, useExisting: OvermindService }
]
})
export class AppModule { }
`,
},
{
fileName: 'components/app.component.ts',
code: `
import { Component, ChangeDetectionStrategy } from '@angular/core'
import { Store } from '../overmind'
@Component({
selector: 'app-root',
template: \`
<div *track>
<h1 (click)="actions.changeTitle()">{{ state.title }}</h1>
</div>
\`,
changeDetection: ChangeDetectionStrategy.OnPush
})
export class AppComponent {
state = this.store.select()
actions = this.store.actions
constructor(private store: Store) {}
},
`,
},
]