ApplicationContext for Node.js

码农软件 · 软件分类 · Node.js 扩展 · 2019-04-15 09:28:12

软件介绍

介绍

这是一个针对 Node.js 方面的ApplicationContext,作用于全局应用的Key-Value的Setter与Getter,并同时具有事件触发响应,重点解决在开发Node.js应用时,缺少良好应用级别的全局变量控制或者配置。

如何使用

npm install applicationcontext --save

API

要求

var AppContext = require('applicationcontext');

Setter & Getter

set([key,]value)

  • key {String}, Optional : 键,形式为 'a.b.c'

  • value {AnyType} : 如果没有key参数,那么这里可以使用原型对象,但是千万要注意的是原型对象中的key绝对不能是'a.b.c'这样的结构,否则get会返回undefined

AppContext.set("username","Jimmy Song");
 console.log(AppContext.get("username"));
 //Use Plain Object like this
 AppContext.set({
 session : { name : "user", expire : 3000 }, 
// do not name key that look like 'a.b.c', it's error  "local.name" : "good" });
 console.log(AppContext.get("session.name"));
 // output : user console.log(AppContext.get("local.name"));
 // output : undefined

get(key)

  • key {String} : e.g AppContext.get('username'); or AppContext.get('session.name')

remove(key)

  • key {String} : e.g AppContext.remove('username'); or AppContext.remove('session.name')

clear()

  • Remove All data

Event

on(key,listener)

// 为某个键添加监听 AppContext.on('session.name',function(value,message){
 // 这里的value是key对应的值,而message是触发事件时可选的消息
 console.log("the value is ",value); console.log("and extra message is ",message);
 });

emit(key,message)

// 触发事件时,传递的如下的消息
 AppContext.set('session.name','Freeman');
 AppContext.emit('session.name','hi, there is extra information, just tell you the session.name value is changed');

off(key [ , listener ] )

// Remove the specified listener for 'session.name'
 AppContext.off('session.name',listener); 
// Remove all listener for 'session.name'
 AppContext.off('session.name');

本文地址:https://www.codercto.com/soft/d/3618.html

期货趋势程序化交易方法

期货趋势程序化交易方法

马文胜 编 / 中国财政经济 / 2008-1 / 42.00元

《期货趋势程序化交易方法》可作为学习期货行业的教程。中国期货行业非常重视期货人才队伍的建设,无论是在抓紧推进期货分析师的认证体系建设、提升期货分析师的执业水平上,还是在专业人才的后续教育上。 要想在期货市场上长期生存并保持稳定的获利,必须在充分认识市场的基础上,建立一个有效的系统化的手段和程序化的方法,把一切的复杂性和不确定性全部加以量化,使所有的交易有序而直观,才能最终达到低风险、低回报。一起来看看 《期货趋势程序化交易方法》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

html转js在线工具
html转js在线工具

html转js在线工具