https://github.com/meepobrother/meepo-event
事件订阅及通知
https://github.com/meepobrother/meepo-event
angular events
Last synced: 2 months ago
JSON representation
事件订阅及通知
- Host: GitHub
- URL: https://github.com/meepobrother/meepo-event
- Owner: meepobrother
- License: mit
- Created: 2018-01-03T01:50:01.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-15T02:28:00.000Z (over 8 years ago)
- Last Synced: 2025-05-22T16:38:03.564Z (about 1 year ago)
- Topics: angular, events
- Language: JavaScript
- Homepage: https://meepo.com.cn
- Size: 1.74 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# event like socket for angular
- 引入
```ts
import { SocketRoom, SocketModule, SocketService } from 'meepo-event';
```
- 注册根room
```ts
SocketModule.forRoot(new SocketRoom('root'))
```
- 注册子room
```ts
SocketModule.forChild(new SocketRoom('index'))
```
```ts
constructor(
public event: SocketService
){
// 监听事件
this.event.on('index',(data)=>{
console.log('index',data);
});
this.event.on('root',(data)=>{
console.log('root',data);
});
}
emit(){
// 触发事件
this.event.emit('index','index test');
this.event.emit('root','root test');
}
```