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

@lume/variable

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lume/variable

Create and react to reactive variables.

  • 0.4.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10
decreased by-23.08%
Maintainers
1
Weekly downloads
 
Created
Source

@lume/variable

Create and react to reactive variables.

npm install @lume/variable --save

React to changes in reactive variables

Here's an example that shows how to make a reactive variable, change the value every second, and make an automatically executed computation that logs the value of the variable to the console any time the variable changes.

import {variable, autorun} from '@lume/variable'

const count = variable(0)

setInterval(() => count(count() + 1), 1000)

// The function (computation) passed into autorun fires every second due to count being incremented every second.
autorun(() => {
	console.log(count())
})

This works because the autorun computation tracks which variables were used, and tracks those variables "dependencies" or requirements of the computation. When any dependency of a computation changes, the computation function will be automatically re-executed.

Keywords

FAQs

Package last updated on 20 Jan 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