Permalink
Cannot retrieve contributors at this time
Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign up
Find file
Copy path
sam-samples/angular4-Bootstrap4-SB-Admin-master/src/app/services/sam.service.ts
Find file
Copy path
Fetching contributors…
| // | |
| import { Component, Injectable } from '@angular/core'; | |
| import { State } from '../state/state'; | |
| import { Model } from '../model/model'; | |
| import { Actions } from '../actions/actions'; | |
| import { View } from '../views/view'; | |
| @Injectable() | |
| export class SamService { | |
| public readonly actions: Actions; | |
| public readonly model: Model; | |
| public readonly state: State; | |
| constructor() { | |
| // view stuffs are handled directly via subscriptions to state in components | |
| // const view = new View(); | |
| this.actions = new Actions(this); | |
| // ********** Migrate Model to Server ************ | |
| this.model = new Model(this); | |
| // let model: any = ModelServer() ; | |
| this.state = new State(this); | |
| // view.init(sr => app.render(sr, actions.dispatcher)) | |
| } | |
| init(services: { type?: 'actions' | 'model', serviceName: string, service: any, init?: boolean }[]) { | |
| services.forEach(service => { | |
| service.type = service.type || 'actions'; | |
| service.init = service.init || false; | |
| if (service.type === 'model') { this.model.addService(service.serviceName, service.service, service.init); } | |
| if (service.type === 'actions') { this.actions.addService(service.serviceName, service.service, service.init); } | |
| }); | |
| console.log('sam service is ready'); | |
| } | |
| } |