byteoss 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -109
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,109 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
## ��װ
|
|
4
|
-
|
|
5
|
-
```
|
|
6
|
-
yarn add topic
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
# ����
|
|
10
|
-
|
|
11
|
-
### publish
|
|
12
|
-
|
|
13
|
-
�����¼�
|
|
14
|
-
|
|
15
|
-
```typescript
|
|
16
|
-
import { topic } from 'topic';
|
|
17
|
-
|
|
18
|
-
topic.publish('name', 'message');
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
### subscribe
|
|
22
|
-
|
|
23
|
-
�����¼�
|
|
24
|
-
|
|
25
|
-
```typescript
|
|
26
|
-
topic.subscribe('who', (name, age) => {
|
|
27
|
-
console.log('Hello' + name + ', are you ' + age + 'old?');
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
topic.publish('who', 'Tom', 12);
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
### subscribeOnce
|
|
34
|
-
|
|
35
|
-
�����¼�������һ�κ�����ȡ��
|
|
36
|
-
|
|
37
|
-
```typescript
|
|
38
|
-
topic.subscribeOnce('who', (name) => {
|
|
39
|
-
console.log('Hello ' + name);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
// ��һ���������յ���Ϣ
|
|
43
|
-
topic.publish('who', 'Tom');
|
|
44
|
-
// û�ж�������
|
|
45
|
-
topic.publish('who', 'Tom');
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### unsubscribe
|
|
49
|
-
|
|
50
|
-
ȡ�������¼�
|
|
51
|
-
|
|
52
|
-
```typescript
|
|
53
|
-
const handle = topic.subscribe('who', (name) => {
|
|
54
|
-
console.log('Hello ' + name);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
// ��һ���������յ���Ϣ
|
|
58
|
-
topic.publish('who', 'Tom');
|
|
59
|
-
// ��һ���������յ���Ϣ
|
|
60
|
-
topic.publish('who', 'John');
|
|
61
|
-
|
|
62
|
-
handle.unsubscribe();
|
|
63
|
-
// û�ж�������
|
|
64
|
-
topic.publish('who', 'Tom');
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### keep + release
|
|
68
|
-
|
|
69
|
-
���������¼�
|
|
70
|
-
|
|
71
|
-
```typescript
|
|
72
|
-
const sub1 = topic.subscribe('who', (name) => {
|
|
73
|
-
console.log('Hello ' + name);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
// sub1 �յ���Ϣ
|
|
77
|
-
const handle = topic.keep('who', true, 'Tom');
|
|
78
|
-
|
|
79
|
-
// sub2 �����յ���Ϣ
|
|
80
|
-
const sub2 = topic.subscribe('who', (name) => {});
|
|
81
|
-
|
|
82
|
-
// sub3 �����յ���Ϣ
|
|
83
|
-
const sub3 = topic.subscribe('who', (name) => {});
|
|
84
|
-
|
|
85
|
-
handle.release();
|
|
86
|
-
|
|
87
|
-
// sub3 û���յ���Ϣ
|
|
88
|
-
const sub3 = topic.subscribe('who', (name) => {});
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
# ʹ�� TS �����Զ����¼�
|
|
92
|
-
|
|
93
|
-
ʵ����� topic ���ǻ������ŵģ�������ȫ��ҵ����߾ֲ�ҵ��
|
|
94
|
-
|
|
95
|
-
```typescript
|
|
96
|
-
import { Topic } from 'topic';
|
|
97
|
-
|
|
98
|
-
const customTopic = new Topic<{
|
|
99
|
-
foo: [name: string];
|
|
100
|
-
bar: [name: string, age: number];
|
|
101
|
-
// ������봫�����ɿص��¼����ƣ���ȡ����������ע��
|
|
102
|
-
// [more: string]: any[];
|
|
103
|
-
}>();
|
|
104
|
-
|
|
105
|
-
// ���ڱ༭������ʾ��name��������
|
|
106
|
-
customTopic.subscribe('foo', (name) => {});
|
|
107
|
-
// ���ڱ༭��֪���ڶ�������Ӧ�ô�ʲô������
|
|
108
|
-
customTopic.publish('foo', 'Tom');
|
|
109
|
-
```
|
|
1
|
+
这是一个静态资源库
|
package/package.json
CHANGED