Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

zen-push

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zen-push

An Observable push stream

  • 0.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is zen-push?

The zen-push npm package provides a simple and efficient way to handle push-based data streams. It is designed to be used in scenarios where you need to manage a sequence of data events, such as in reactive programming or when dealing with asynchronous data flows.

What are zen-push's main functionalities?

Basic Push Stream

This feature allows you to create a basic push stream where you can push values and subscribe to receive those values. The code sample demonstrates creating a push stream, subscribing to it, and pushing values to the stream.

const Push = require('zen-push');
const push = new Push();

// Subscribe to the stream
push.observable.subscribe({
  next: value => console.log('Received:', value),
  error: err => console.error('Error:', err),
  complete: () => console.log('Stream complete')
});

// Push values to the stream
push.next('Hello');
push.next('World');
push.complete();

Error Handling

This feature demonstrates how to handle errors in the push stream. The code sample shows how to push an error to the stream and handle it in the subscription.

const Push = require('zen-push');
const push = new Push();

// Subscribe to the stream with error handling
push.observable.subscribe({
  next: value => console.log('Received:', value),
  error: err => console.error('Error:', err),
  complete: () => console.log('Stream complete')
});

// Push values and an error to the stream
push.next('Hello');
push.error(new Error('Something went wrong!'));

Completion Handling

This feature shows how to handle the completion of the push stream. The code sample demonstrates pushing values to the stream and then completing it, triggering the completion handler in the subscription.

const Push = require('zen-push');
const push = new Push();

// Subscribe to the stream with completion handling
push.observable.subscribe({
  next: value => console.log('Received:', value),
  error: err => console.error('Error:', err),
  complete: () => console.log('Stream complete')
});

// Push values and complete the stream
push.next('Hello');
push.next('World');
push.complete();

Other packages similar to zen-push

FAQs

Package last updated on 28 Oct 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc