Angular
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({
providedIn: 'root'
})
export class Store extends OvermindService<typeof config> {}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, useFactory: () => createOvermind(config) },
{ provide: Store, useExisting: OvermindService }
]
})
export class AppModule { }
import { Component, ChangeDetectionStrategy } from '@angular/core'
import { Store } from '../overmind'
@Component({
selector: 'app-root',
template: `
<div *track>
<h1 (click)="actions.changeAdminTitle()">{{ state.adminTitle }}</h1>
</div>
`,
changeDetection: ChangeDetectionStrategy.OnPush
})
export class AppComponent {
state = this.store.select(state => state.admin)
actions = this.store.actions.admin
constructor(private store: Store) {}
},Polyfill environment
NgZone
Rendering
Passing state as input
Reactions
Last updated