K-Observable
This is a basic observable implementation to hold data and get notified whenever it changes. Inspired by the well-known KnockoutJS observable objects, but without any other magic (like bindings or dependency tracking). Just observables and subscriptions.
Observable
The most basic unit: you can store and retrieve data from them.
;;name.subscribeconsole.log`The new name is ''`;name'foo';// sets the name//The new name is fooname;// gets the name
Computed
Given a number of observables, you can perform some aggregation conversion and get it like another read-only observable.
;;;;;canSubmit.subscribemySubmitButton.disabled = !can;user'';// disables the buttonpassword'';// the button remains disableduser'me';// the button remains disabledpassword'me again';// enables the button
Powered by TypeScript
If your IDE has TypeScript running (with a plugin, see more at https://www.typescriptlang.org/), you can:
- Code in JavaScript and see how your IDE autocompletes all the K-Observable usages, with type inferences and so on. You can see an example under the test folder.
- Code in TypeScript and... you know, TypeScript!
Compile
npm install && npm run build
Test
npm test