Install the package
Use the same published version as this showcase, or review the upstream release notes before updating. The RxJS peer is installed alongside the package.
npm install @wieslawsoltes/reactiveweb@0.2.0 rxjs@7.8.2This package’s license: MIT. Retain upstream and bundled third-party notices when redistributing.
Mount your first view
Install rxjs. Use the root entry for view models and /html for DOM bindings. React integration is an optional separate adapter.
<div class="toolbar"><label>First name <input id="first" value="Alex"></label><label>Last name <input id="last" value="Morgan"></label><button id="save">Create greeting</button></div><div class="panel"><p class="hint">COMPUTED, NOT COPIED</p><h1 id="name"></h1><p>A live view of two reactive properties.</p><output id="message">Edit either field. This view follows the model.</output></div>The complete executable source is in the usage guide. Imports shown here are intended for a bundler or a browser import map; bare npm imports do not resolve in ordinary HTML by themselves.
Own the lifetime
Collect subscriptions, bindings and owned view models in a CompositeDisposable and dispose it with the view.
The playground replaces its entire isolated frame on each run. In your application, use the framework’s unmount or disposal hook instead. Do not dispose a shared model while another view still owns it.
Read the lifecycle guide →Know the contract
Source repositories can contain work newer than the published package. The showcase uses @wieslawsoltes/reactiveweb@0.2.0.