@@ -19,8 +19,8 @@ describe('app.publish', () => {
19
19
}
20
20
} ) ;
21
21
22
- app . service ( 'test' ) . publish ( 'created' , function ( ) { } ) ;
23
- app . service ( 'test' ) . publish ( 'bla' , function ( ) { } ) ;
22
+ app . service ( 'test' ) . registerPublisher ( 'created' , function ( ) { } ) ;
23
+ app . service ( 'test' ) . registerPublisher ( 'bla' , function ( ) { } ) ;
24
24
assert . ok ( false , 'Should never get here' ) ;
25
25
} catch ( e ) {
26
26
assert . strictEqual ( e . message , `'bla' is not a valid service event` ) ;
@@ -45,7 +45,7 @@ describe('app.publish', () => {
45
45
it ( 'simple event registration and dispatching' , done => {
46
46
app . channel ( 'testing' ) . join ( c1 ) ;
47
47
48
- app . service ( 'test' ) . publish ( 'created' , ( ) => app . channel ( 'testing' ) ) ;
48
+ app . service ( 'test' ) . registerPublisher ( 'created' , ( ) => app . channel ( 'testing' ) ) ;
49
49
50
50
app . once ( 'publish' , ( event : string , channel : Channel , hook : HookContext ) => {
51
51
assert . strictEqual ( event , 'created' ) ;
@@ -65,8 +65,8 @@ describe('app.publish', () => {
65
65
app . channel ( 'testing' ) . join ( c1 ) ;
66
66
app . channel ( 'other' ) . join ( c2 ) ;
67
67
68
- app . publish ( 'created' , ( ) => app . channel ( 'testing' ) ) ;
69
- app . publish ( ( ) => app . channel ( 'other' ) ) ;
68
+ app . registerPublisher ( 'created' , ( ) => app . channel ( 'testing' ) ) ;
69
+ app . registerPublisher ( ( ) => app . channel ( 'other' ) ) ;
70
70
71
71
app . once ( 'publish' , ( _event : string , channel : Channel ) => {
72
72
assert . ok ( channel . connections . indexOf ( c1 ) !== - 1 ) ;
@@ -82,12 +82,12 @@ describe('app.publish', () => {
82
82
app . channel ( 'testing' ) . join ( c1 ) ;
83
83
app . channel ( 'othertest' ) . join ( c2 ) ;
84
84
85
- app . service ( 'test' ) . publish ( 'created' , ( ) =>
85
+ app . service ( 'test' ) . registerPublisher ( 'created' , ( ) =>
86
86
new Promise ( resolve =>
87
87
setTimeout ( ( ) => resolve ( app . channel ( 'testing' ) ) , 50 )
88
88
)
89
89
) ;
90
- app . service ( 'test' ) . publish ( 'created' , ( ) =>
90
+ app . service ( 'test' ) . registerPublisher ( 'created' , ( ) =>
91
91
new Promise ( resolve =>
92
92
setTimeout ( ( ) => resolve ( app . channel ( 'testing' , 'othertest' ) ) , 100 )
93
93
)
@@ -110,7 +110,7 @@ describe('app.publish', () => {
110
110
app . channel ( 'testing' ) . join ( c1 ) ;
111
111
app . channel ( 'othertest' ) . join ( c2 ) ;
112
112
113
- app . service ( 'test' ) . publish ( 'foo' , ( ) => app . channel ( 'testing' ) ) ;
113
+ app . service ( 'test' ) . registerPublisher ( 'foo' , ( ) => app . channel ( 'testing' ) ) ;
114
114
115
115
app . once ( 'publish' , ( event : string , channel : Channel , hook : HookContext ) => {
116
116
assert . strictEqual ( event , 'foo' ) ;
@@ -141,7 +141,7 @@ describe('app.publish', () => {
141
141
} ) ;
142
142
143
143
it ( 'does not send `dispatch` event if there are no connections' , done => {
144
- app . service ( 'test' ) . publish ( 'created' , ( ) =>
144
+ app . service ( 'test' ) . registerPublisher ( 'created' , ( ) =>
145
145
app . channel ( 'dummy' )
146
146
) ;
147
147
app . once ( 'publish' , ( ) =>
@@ -158,7 +158,7 @@ describe('app.publish', () => {
158
158
app . channel ( 'testing' ) . join ( c1 ) ;
159
159
app . channel ( 'othertest' ) . join ( c2 ) ;
160
160
161
- app . service ( 'test' ) . publish ( 'created' , ( ) => [
161
+ app . service ( 'test' ) . registerPublisher ( 'created' , ( ) => [
162
162
app . channel ( 'testing' ) ,
163
163
app . channel ( 'othertest' )
164
164
] ) ;
@@ -180,7 +180,7 @@ describe('app.publish', () => {
180
180
app . channel ( 'testing' ) . join ( c1 ) ;
181
181
app . channel ( 'othertest' ) . join ( c2 ) ;
182
182
183
- app . service ( 'test' ) . publish ( 'created' , ( ) => [
183
+ app . service ( 'test' ) . registerPublisher ( 'created' , ( ) => [
184
184
app . channel ( 'testing' ) . send ( c1data ) ,
185
185
app . channel ( 'othertest' )
186
186
] ) ;
@@ -199,8 +199,8 @@ describe('app.publish', () => {
199
199
it ( 'publisher precedence and preventing publishing' , done => {
200
200
app . channel ( 'test' ) . join ( c1 ) ;
201
201
202
- app . publish ( ( ) => app . channel ( 'test' ) ) ;
203
- app . service ( 'test' ) . publish ( 'created' , ( ) : null => null ) ;
202
+ app . registerPublisher ( ( ) => app . channel ( 'test' ) ) ;
203
+ app . service ( 'test' ) . registerPublisher ( 'created' , ( ) : null => null ) ;
204
204
205
205
app . once ( 'publish' , ( ) => done ( new Error ( 'Should never get here' ) ) ) ;
206
206
@@ -213,7 +213,7 @@ describe('app.publish', () => {
213
213
app . channel ( 'testing' ) . join ( c1 ) ;
214
214
app . channel ( 'othertest' ) . join ( c1 ) ;
215
215
216
- app . service ( 'test' ) . publish ( 'created' , ( ) => {
216
+ app . service ( 'test' ) . registerPublisher ( 'created' , ( ) => {
217
217
return [
218
218
app . channel ( 'testing' ) ,
219
219
app . channel ( 'othertest' ) . send ( sendData )
0 commit comments