一个简单的发布订阅模式库 支持类型提示和优先级

github
yxdtg/msgm: msgm 是一个拥抱类型安全的发布订阅模式库 并且可以控制优先级 (github.com)
npm
msgm - npm (npmjs.com)
欢迎大家使用

提个建议,保证类型可以换个方式,会更好用

/**
 * 类型配置
 */
interface TypeMap {
    "event": string;
    "hello": string;
}

const msg = new Msgm<TypeMap>();
1赞

真是个好建议,感谢,已更新…

提个建议 增加回调目标好点,要不注册的时候还要绑定
Imessage{
/**回调目标 */
public target: any;
}
message.cb.call(message.target,data);

1赞

可以参考下 tsrpc 消息部分的源码

1赞

感谢,已更新…

yx-pubsub 重新设计
yx-pubsub - npm (npmjs.com)

  • 轻量无依赖 :zap:
  • 类型安全 :rescue_worker_helmet:
  • 消息回调顺序 :love_letter:
  • 多参数回调 :books:
  • this指向绑定 :telephone_receiver:
  • 无类型模式 :rocket:
1赞

这个有啥用