remix-project mirror
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
remix-project/src/remixAppManager.js

45 lines
1.1 KiB

import { AppManagerApi } from 'remix-plugin'
import { EventEmitter } from 'events'
export class RemixAppManager extends AppManagerApi {
constructor (store) {
super(null)
this.store = store
this.event = new EventEmitter()
}
doActivate (name) {
this.activateOne(name)
// temp
this.store.activate(name)
// promise ?
const entity = this.getEntity(name)
if (entity.profile.icon && entity.api.render && typeof entity.api.render === 'function') {
this.event.emit('requestContainer', entity.profile, entity.api.render())
}
}
doDeactivate (name) {
this.deactivateOne(name)
// temp
this.store.deactivate(name)
// promise ?
const entity = this.getEntity(name)
if (entity.profile.icon && entity.api.render && typeof entity.api.render === 'function') {
this.event.emit('removingItem', entity.profile)
}
}
setActive (name, isActive) {
isActive ? this.store.activate(name) : this.store.deactivate(name)
}
getEntity (entityName) {
return this.store.get(entityName)
}
addEntity (entity) {
this.store.add(entity.profile.name, entity)
}
}