@conclurer/message-stream
TypeScript icon, indicating that this package has built-in type declarations

6.8.0-beta.1 • Public • Published

Message Stream

How to Use

To use the MessageStreamService, you have to provide it in your component or module first.

import {Component} from '@angular/core';
import {MessageStreamService} from '@conclurer/message-stream';

@Component({
  providers: [
    MessageStreamService,
  ],
})
export class YourComponent {
}

MessageStreamService allows you to create one or more streams for objects. After the stream is initialized, you can listen to events or emit new messages:

import {MessageStreamService} from '@conclurer/message-stream';

export class YourComponent {
  constructor(
    private readonly messageStream: MessageStreamService,
  ) {
    const stream = this.messageStream.streamFor('YOUR OBJECT UUID');

    // Subscribes to all messages
    stream.message$.subscribe();

    // Subscribes to the ids of all subscribers of the same object
    stream.activeSubscriberIds$.subscribe();

    // Emits the given data to the server and therefor all subscribers of this object.
    stream.emit({your: 'data'});
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i @conclurer/message-stream

Weekly Downloads

0

Version

6.8.0-beta.1

License

none

Unpacked Size

86.7 kB

Total Files

18

Last publish

Collaborators

  • chrisconclurer
  • maxzeger
  • julian_bm
  • lemonlime
  • can557
  • mc17uulm
  • marvinscharle