feat: add type definition to signal recipients
follows more the notifications way of setting recipients and is more future proof Signed-off-by: Heikki Hellgren <heikki.hellgren@op.fi>
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { DefaultSignalsService } from './DefaultSignalsService';
|
||||
import { SignalPayload } from './types';
|
||||
|
||||
describe('DefaultSignalsService', () => {
|
||||
const mockEvents = {
|
||||
@@ -24,9 +25,9 @@ describe('DefaultSignalsService', () => {
|
||||
const service = DefaultSignalsService.create({ events: mockEvents });
|
||||
|
||||
it('should publish signal', () => {
|
||||
const signal = {
|
||||
const signal: SignalPayload = {
|
||||
channel: 'test-channel',
|
||||
recipients: null,
|
||||
recipients: { type: 'broadcast' },
|
||||
message: { msg: 'hello world' },
|
||||
};
|
||||
service.publish(signal);
|
||||
|
||||
@@ -25,7 +25,9 @@ export type SignalsServiceOptions = {
|
||||
|
||||
/** @public */
|
||||
export type SignalPayload<TMessage extends JsonObject = JsonObject> = {
|
||||
recipients: string[] | string | null;
|
||||
recipients:
|
||||
| { type: 'user'; entityRefs: string | string[] }
|
||||
| { type: 'broadcast' };
|
||||
channel: string;
|
||||
message: TMessage;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user