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

@beyond-js/dynamic-processor

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@beyond-js/dynamic-processor

The context on which the DynamicProcessor is designed, is when there is an asynchronous processing, and where you want to access the processed data synchronously, once the asynchronous processing has finished.

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Introduction

The context on which the DynamicProcessor is designed, is when there is an asynchronous processing, and where you want to access the processed data synchronously, once the asynchronous processing has finished.

The general logic of the processor is that it starts in an inactive state, and once started, it is kept up-to-date by processing each time it is invalidated and as long as it has already been started. As the consumption of the DynamicProcessor data is synchronous, the data must be consumed after waiting for the .ready promise, or after receiving change notifications ('change' event). The 'change' event guarantees that the data has already been previously processed.

Processor usage is as follows:

1- Access the .ready property

  • await processor.ready;

2- Listen for changes

  • processor.on ('change', listener);

Characteristics

  • The processor does not execute processing until it is initialized.
  • If the .ready property (await processor.ready) is accessed, the processor is initialized, therefore processing is executed.
  • If the processor is invalidated, and it has already been initialized, then the .process method is executed automatically.
  • It emits change events every time it is processed again, starting from the second processing. The first processing is considered the initial state, and each additional processing, a change of the state of the processor.

Considerations

  • The initialise() method internally calls the _process() method. The processor is considered initialized when it has already been processed for the first time.

Problems that DynamicProcessor solves

  • Invalidating the object (execute ._invalidate()) implies reprocessing it, but only if it has already been initialized.
  • The _process (request) method receives the request parameter that allows, after executing any asynchronous function, to verify if it should continue processing or cancel the execution.
_process(request) {
  await asyncMethod ();
  if (this._request! == request) return; // Cancel execution
}
  • If the object is invalidated while processing, DynamicProcessor rerun the _process method automatically.

FAQs

Package last updated on 21 Dec 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