监视模型节点js的状态

时间:2016-08-30 15:32:33

标签: javascript node.js state-machine

我想监控模型的状态,该模型负责为HR和候选人呈现不同的视图。取决于工作,当候选人申请时,有三种可能性(它会增长,这就是我提出问题的原因),回答问题,或者只是进行测试任务或者有测试任务并回答问题。人力资源取决于申请人在哪个阶段有自定义视图,而申请人,根据他们的阶段应该有他们的自定义视图。因此,在JobApplication模型中,columns中的client_view | hr_view | requirements requirements会保存两个"assignment:questions"步骤。例如questions | client_view | hr_view | requirements | ---------------------------------------------------- "active_questions" "not_active" "questions" | client_view | hr_view | requirements | ---------------------------------------------------- "active_assignment" "active" "assignment"

PATCH

States

每次应用程序中的客户端发出'use strict'; class ApplicationState { constructor(requirements) { this._states = { questions: { client_view: 'active_questions', hr_view: 'not_active' }, assignment: { client_view: 'active_assignment', hr_view: 'active' }, done: { client_view: 'not_active', hr_view: 'active' } }; this.requirements = requirements; this.current = requirements.length === 1 ? this._states[requirements[0]] : this._states.questions; } next () { if (this.current === this._states.questions && this.requirements.indexOf('assignment') !== -1) { this.current = this._states.assignment; } else { this.current = this._states.done; } } } module.exports = ApplicationState; 请求时,都应对模型进行更改。目前我提出了非常糟糕的无标度解决方案

var applicationState = new ApplicationState(applicationModel.requirements)
applicationModel.setStates(applicationState.next())

在我的模型中,我调用它

x

0 个答案:

没有答案