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

dynamic-on-change

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

dynamic-on-change

An utility for managing on change functions

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

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

dynamic-on-change

An utility for managing on change functions. This is meant to be used with react components for avoiding binding instance methods.

Typescript support. Made in typescript ;)

Example

import dynamicOnChange from "./index";
const a = {
  hello: "world",
  foo: 3,
};
const onChange = dynamicOnChange<typeof a>((key, value) => {
  a[key] = value;
});
onChange.foo(5);
expect(a).toMatchObject({ hello: "world", foo: 5 });
onChange.hello("me");
expect(a).toMatchObject({ hello: "me", foo: 5 });

// invalid in typescript
onChange.foo("hello"); // error: Argument of type '"hello"' is not assignable to parameter of type 'number'.
onChange.hello(3); // error: Argument of type '3' is not assignable to parameter of type 'string'.
onChange.asdf("me"); // error: Property 'asdf' does not exist on type 'dynamicOnChanges<{ hello: string; foo: number; }>'.

Keywords

FAQs

Package last updated on 23 Oct 2018

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