{"id":15230,"library":"rx-lite","title":"RxJS Lite (Legacy v4)","description":"rx-lite is a lightweight distribution of the Reactive Extensions for JavaScript (RxJS) version 4.x, primarily used for composing asynchronous and event-based operations in JavaScript. At version 4.0.8, it provided a core set of observable operators for handling events, promises, callbacks, and time-based operations in both modern browser environments (IE9+) and Node.js. The library was part of an earlier generation of RxJS, with its development repository transitioning to 'RxJS vNext' (which became RxJS v5 and later) after the 4.x series. This version prioritizes a compact bundle (`rx.lite.js`) for everyday use cases, differing from the more modular, tree-shakable approach adopted in subsequent major RxJS releases. It had an irregular release cadence, focusing on bug fixes and performance improvements within the 3.x and 4.x lines before the major architectural shift to modern RxJS.","status":"abandoned","version":"4.0.8","language":"javascript","source_language":"en","source_url":"https://github.com/Reactive-Extensions/RxJS","tags":["javascript","React","Reactive","Events","Rx","RxJS"],"install":[{"cmd":"npm install rx-lite","lang":"bash","label":"npm"},{"cmd":"yarn add rx-lite","lang":"bash","label":"yarn"},{"cmd":"pnpm add rx-lite","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"RxJS v4 is a CommonJS module for Node.js. ESM import syntax is not supported and will fail.","wrong":"import Rx from 'rx-lite';","symbol":"Rx","correct":"const Rx = require('rx-lite');"},{"note":"Observable is a property of the global 'Rx' object, not a named export.","wrong":"import { Observable } from 'rx-lite';","symbol":"Observable","correct":"const Rx = require('rx-lite');\nconst Observable = Rx.Observable;"},{"note":"Operators are attached to Rx.Observable. Named ESM imports are not available in this version.","wrong":"import { fromPromise } from 'rx-lite';","symbol":"fromPromise","correct":"const Rx = require('rx-lite');\nconst myObservable = Rx.Observable.fromPromise(somePromise);"}],"quickstart":{"code":"const Rx = require('rx-lite');\n\nconst source = Rx.Observable.fromArray([1, 2, 3, 4, 5]);\n\nconst subscription = source\n  .map(x => x * 2)\n  .filter(x => x > 5)\n  .subscribe(\n    x => console.log('Next: ' + x),\n    err => console.error('Error: ' + err),\n    () => console.log('Completed')\n  );\n\n// Example with a promise\nconst somePromise = Promise.resolve('Hello from Promise!');\nRx.Observable.fromPromise(somePromise)\n  .subscribe(\n    data => console.log('Promise data: ' + data),\n    err => console.error('Promise error: ' + err)\n  );\n\n// To stop listening (important for long-lived observables)\n// subscription.dispose();","lang":"javascript","description":"Demonstrates creating an observable from an array, applying map and filter operators, and subscribing to log values. Also shows converting a Promise to an Observable."},"warnings":[{"fix":"Migrate to the current `rxjs` package (`npm install rxjs`). This involves rewriting import statements and potentially many operator calls due to API changes.","message":"This `rx-lite` package is for RxJS v4. Development transitioned to 'RxJS vNext' (modern `rxjs` v5+), which introduced significant breaking changes, API rewrites, and a new modular import system. `rx-lite` is not compatible with modern RxJS.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Use `require('rx-lite')` for Node.js environments. For browser usage, include `rx.lite.js` via a `<script>` tag, which exposes `Rx` globally.","message":"RxJS v4, including `rx-lite`, primarily targets CommonJS for Node.js and global script tags for browsers. It does not support native ES Modules (ESM) `import` syntax, which will lead to errors.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Upgrade to `rx-lite` version 4.0.6 or newer. If upgrading is not possible, ensure robust error handling within your promises before converting them to Observables.","message":"In versions prior to 4.0.6, `Rx.Observable.fromPromise(promise)` was known to swallow errors originating from Observable instances within the promise chain, leading to silent failures.","severity":"breaking","affected_versions":"<4.0.6"},{"fix":"Use `npm install rxjs` for new projects or when migrating. Consult the official RxJS documentation for current best practices.","message":"The package name `rx-lite` is an artifact of RxJS v4. Modern RxJS uses the package name `rxjs` and does not differentiate between 'lite' and 'core' versions in the same way, as it is tree-shakable by default.","severity":"deprecated","affected_versions":">=4.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Use CommonJS `require`: `const Rx = require('rx-lite'); const Observable = Rx.Observable;`","cause":"Attempting to use ES module import syntax (`import { Observable } from 'rx-lite';`) with a CommonJS-only package.","error":"TypeError: (0, _rxLite.Observable) is not a constructor"},{"fix":"For browser usage, include the `rx.lite.js` file via a `<script>` tag. For bundled applications, ensure your bundler is correctly configured to handle CommonJS modules.","cause":"Using `require('rx-lite')` directly in a browser environment without a CommonJS bundler (like Webpack or Browserify).","error":"ReferenceError: require is not defined"},{"fix":"Ensure `rx.lite.js` is loaded via a `<script>` tag before your code, or add `const Rx = require('rx-lite');` at the top of your Node.js file.","cause":"Trying to use `Rx` in the browser without loading the `rx.lite.js` script, or in Node.js without `require('rx-lite')`.","error":"ReferenceError: Rx is not defined"}],"ecosystem":"npm"}