
Security News
GitHub Actions Pricing Whiplash: Self-Hosted Actions Billing Change Postponed
GitHub postponed a new billing model for self-hosted Actions after developer pushback, but moved forward with hosted runner price cuts on January 1.
angular-sse-client
Advanced tools
This library is a wrapper for SSE for angular.
What is SSE?
(Server-sent events - Web APIs, An EventSource instance opens a persistent connection to an HTTP server, which sends events in text/event-stream format. The connection remains open until closed by calling EventSource.close().).
NOTE:
This lib requires typescript 2.7+, see Support 'EventSource' in lib.dom.d.ts · Issue #13666 · microsoft/TypeScript
See EventSource#Browser compatibility
NOTE:
You may need to use a polyfill to make it work on more versions of browsers: EventSource/eventsource: EventSource client for Node.js and Browser (polyfill)
npm install angular-sse-client --save
Inject the SseClient or create a new one, then call the get method with an SSE url:
import { SseClient } from 'angular-sse-client';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.less']
})
export class AppComponent implements OnInit {
constructor(private sseClient: SseClient) {
}
ngOnInit(): void {
this.sseClient.get('http://localhost:8181/sse')
.subscribe(data => {
console.log('got data from EventSource', data);
});
}
}
If you want to listen to the event source for only amount of time, set duration option, i.e. the Observable will be unsubscribed after duration time:
this.sseClient.get('http://localhost:8181/sse', { duration: 5000 })
.subscribe(data => {
console.log('got data from EventSource', data);
});
If you want to keep the event source alive after unsubscribing an sseClient, set keepAlive to true, so that other clients listening to the same url will not be affected, i.e. other calls of sseClient.get(url, ...) will still get response from the only one EventSource targeting to that url (by utilizing an event source pool internally):
This option can make sse clients share the same source, so the maxium connection limitation of SSE connections will be avoided in some extent. See SSE suffers from a limitation to the maximum number of open connections, which can be specially painful when opening various tabs as the limit is per browser and set to a very low number (6)
this.sseClient.get('http://localhost:8181/sse', { keepAlive: true })
.subscribe(data => {
console.log('got data from EventSource', data);
});
NOTE: To close the
'alive'event source manually, use:
import { closeEventSource } from 'angular-sse-client';
closeEventSource('http://localhost:8181/sse');
// SseClient
get(url: string, options: {
withCredentials?: boolean,
/**
* Complete the observable after a period of time automatically
*/
duration?: number,
/**
* If set to true, keep event source open (i.e. will not close and keep it in a event source pool for reuse) after unsubscribing
*/
keepAlive?: boolean,
} = {}): Observable<any>
Run ng build angular-sse-client to build the project. The build artifacts will be stored in the dist/ directory.
After building your library with ng build angular-sse-client, go to the dist folder cd dist/angular-sse-client and run npm publish.
Run ng test angular-sse-client to execute the unit tests via Karma.
FAQs
This library is a wrapper for SSE for angular.
The npm package angular-sse-client receives a total of 5 weekly downloads. As such, angular-sse-client popularity was classified as not popular.
We found that angular-sse-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
GitHub postponed a new billing model for self-hosted Actions after developer pushback, but moved forward with hosted runner price cuts on January 1.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.