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

kapsel

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kapsel

Data with additives in one capsule

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

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

kapsel

Data and service information in one capsule.

Installation

npm i kapsel

Usage

const kapsel = new Kapsel('Init Data');

kapsel.subscribe(({isLoading, data}) => {
    console.log({isLoading, data});
});

const provider = {
    get: () => {
      return new Promise((res) => setTimeout(() => res('Useful data'), 1000))
    }
};

kapsel.fill(provider.get());

// console.log shows:
// {isLoading: true, data: 'Init Data'}

// one second later console.log shows  
// {isLoading: false, data: 'Useful data'}

Params

initial: any - default value

defer?: () => Promise<any> - will be called when the data is read for the first time. Works only one time

API

data: any - current data

prev: any - previous data

isLoading: boolean - is in the process of filling in

error: Error | null - filling process error

hasError: boolen - true if error not null

fill: (promise: Promise<any>) => void - method for filling with data

subscribe: (kapsel: Kapsel) => void - adds a callback that will be called for any state change

unsubscribe: (kapsel: Kapsel) => void - removes the callback

Keywords

FAQs

Package last updated on 18 Jun 2023

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