Socket
Book a DemoInstallSign in
Socket

@distributedlab/reactivity

Package Overview
Dependencies
Maintainers
5
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@distributedlab/reactivity

Implementation of the reactivity connections to propagate changes between objects

1.0.0-rc.17
latest
Source
npmnpm
Version published
Maintainers
5
Created
Source

@distributedlab/reactivity

Implementation of the reactivity connections to propagate changes between objects.

version (scoped package) types tree-shaking checks

Example

Basic usage:

import { ref, computed, toRaw } from '@distributedlab/reactivity'

const newPerson = () => {
  const age = ref(30)
  const name = computed(() => 'John')

  const changeAge = (newAge: number) => {
    age.value = newAge
  }

  return toRaw({ age, name, changeAge })
}

const john = newPerson()

console.log(john.age) // 30
console.log(john.name) // John

obj.changeAge(35)

console.log(john.age) // 35

Usage with extending:

const newHuman = () => {
  const age = ref(25)

  const changeAge = (newAge: number) => {
    age.value = newAge
  }

  return toRaw({ age, changeAge })
}

const newPerson = () => {
  const parent = newHuman()
  const name = computed(() => 'John')
  return toRaw(extend(parent, { name }))
}

const person = newPerson()

console.log(person.age) // 25

person.changeAge(30)

console.log(person.age) // 30

Changelog

For the change log, see CHANGELOG.md.

FAQs

Package last updated on 26 Sep 2024

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.