Socket
Socket
Sign inDemoInstall

@effection/channel

Package Overview
Dependencies
Maintainers
1
Versions
130
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@effection/channel

MPMC Channel implementation for effection


Version published
Weekly downloads
1.5K
decreased by-28.17%
Maintainers
1
Weekly downloads
 
Created
Source

@effection/channel

A multi producer, multi consumer unbounded channel for Effection. Channels are useful for communicating between different parts of a system, for building pubsub buses, or a whole lot of other synchronization needs.

Sending to a channel is synchronous and does not require the sender to be running in an effection context. However, reading from a channel can only be done through operations.

Because of the synchronous nature of sends, channels are unbounded in size, which means that they cannot handle backpressure. As such, channels should be used more as a synchronization mechanism, rather than a high-throughput system.

Usage

A basic example:

import { createChannel } from '@effection/channel';
import { main } from '@effection/main';
import { sleep } from '@effection/core';

main(function*() {
  let channel = createChannel();

  spawn(function*() {
    while(true) {
      yield sleep(1000);
      channel.send({ message: "ping" });
    }
  });

  let subscription = yield channel.subscribe();

  while(true) {
    let { value } = yield subscription.next();
    console.log("value:", value);
  }
});

FAQs

Package last updated on 03 Aug 2021

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