{"id":20187009,"url":"https://github.com/material-motion/indefinite-observable-js","last_synced_at":"2025-05-16T05:04:58.398Z","repository":{"id":57273347,"uuid":"75429575","full_name":"material-motion/indefinite-observable-js","owner":"material-motion","description":"An Observable for JavaScript that never calls complete or error","archived":false,"fork":false,"pushed_at":"2025-02-12T19:50:18.000Z","size":599,"stargazers_count":68,"open_issues_count":9,"forks_count":19,"subscribers_count":15,"default_branch":"develop","last_synced_at":"2025-04-08T15:06:46.079Z","etag":null,"topics":["javascript","observables","typescript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/material-motion.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-02T20:45:16.000Z","updated_at":"2024-11-07T09:28:35.000Z","dependencies_parsed_at":"2024-06-18T13:48:45.295Z","dependency_job_id":"1402f94d-1060-4497-9f4f-618dafd7149b","html_url":"https://github.com/material-motion/indefinite-observable-js","commit_stats":{"total_commits":79,"total_committers":3,"mean_commits":"26.333333333333332","dds":0.05063291139240511,"last_synced_commit":"d037e12fca62736dad8c8535fed4207832c25735"},"previous_names":[],"tags_count":59,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/material-motion%2Findefinite-observable-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/material-motion%2Findefinite-observable-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/material-motion%2Findefinite-observable-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/material-motion%2Findefinite-observable-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/material-motion","download_url":"https://codeload.github.com/material-motion/indefinite-observable-js/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254261749,"owners_count":22041265,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","observables","typescript"],"created_at":"2024-11-14T03:19:33.574Z","updated_at":"2025-05-16T05:04:58.381Z","avatar_url":"https://github.com/material-motion.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Indefinite Observable #\n\n\u003c!-- TODO: update version number before releasing, here and in the script tag --\u003e\n[![Current version:](https://img.shields.io/badge/v2.0.1:-222222.svg?logo=npm)](https://www.npmjs.com/package/indefinite-observable/v/2.0.1)\n[![Test status](https://img.shields.io/circleci/project/github/material-motion/indefinite-observable-js/stable.svg?logo=circleci\u0026label=Tests)](https://circleci.com/gh/material-motion/indefinite-observable-js/48)\n[![Code coverage](https://img.shields.io/codecov/c/github/material-motion/indefinite-observable-js/stable.svg?logo=codecov\u0026logoColor=white\u0026label=Coverage)](https://codecov.io/gh/material-motion/indefinite-observable-js/tree/f601df73be779477218f1fcf709b18e6b621de20/src)\u003cbr /\u003e\n[![HEAD:](https://img.shields.io/badge/HEAD:-222222.svg?logo=github\u0026logoColor=white)](https://github.com/material-motion/indefinite-observable-js)\n[![Test status](https://img.shields.io/circleci/project/github/material-motion/indefinite-observable-js/develop.svg?logo=circleci\u0026label=Tests)](https://circleci.com/gh/material-motion/indefinite-observable-js/tree/develop)\n[![Code coverage](https://img.shields.io/codecov/c/github/material-motion/indefinite-observable-js/develop.svg?logo=codecov\u0026logoColor=white\u0026label=Coverage)](https://codecov.io/gh/material-motion/indefinite-observable-js/branch/develop)\n\n## Why? ##\n\nThere are a lot of great Observable implementations, but they're baked into featureful libraries which contribute to both complexity and filesize.  We wanted the simplest-possible Observable implementation, with no operators, no fancy scheduling.  The entire thing is basically [three statements in `subscribe`](https://github.com/material-motion/indefinite-observable-js/blob/develop/src/IndefiniteObservable.ts#L68-L72).\n\nIndefinite Observable is a subset of the [TC39 Observable proposal](https://tc39.github.io/proposal-observable/) that never `complete`s or `error`s.  It implements the [minimal-necessary functionality](https://en.wikipedia.org/wiki/You_aren't_gonna_need_it), but it should be completely interchangeable with the TC39 proposal for the subset that it does implement.\n\nIf you want a complete Observables library that works out-of-the-box, check out [xstream](https://github.com/staltz/xstream/), [RxJS](https://github.com/ReactiveX/RxJS/), [Most](https://github.com/cujojs/most/), [Bacon](https://github.com/baconjs/bacon.js/), or [Kefir](https://github.com/rpominov/kefir/).  If you want to build your own Observables library that includes just the functionality you need, try [Indefinite Observable](https://github.com/material-motion/indefinite-observable-js/#indefinite-observable).\n\n## Usage ##\n\n```javascript\nimport { IndefiniteObservable } from 'indefinite-observable';\n\nconst moveEvent$ = new IndefiniteObservable(\n  (observer) =\u003e {\n    // Whenever you want the observable to dispatch a value, call\n    // observer.next(value).\n    element.addEventListener('pointermove', observer.next);\n\n    // Return a function that will perform any necessary clean up when the\n    // observable is unsubscribed from.\n    return () =\u003e {\n      element.removeEventListener('pointermove', observer.next);\n    }\n  }\n);\n\n// To receive the values dispatched by an observable, pass an observer to its\n// subscribe method.  An observer is just an object with a next method.\n//\n// subscribe returns a unsubscribe function.  Call that when you no longer want\n// to receive dispatches from the observable.\nconst unsubscribe = moveEvent$.subscribe({\n  next(moveEvent) {\n    console.log('got a pointer event: ', moveEvent);\n  }\n});\n```\n\nLearn more about [How Indefinite Observables work](https://material-motion.github.io/material-motion/documentation/IndefiniteObservable).\n\n## Installation ##\n\n```\nyarn add indefinite-observable\n```\n\nor include as a script tag:\n\n```html\n\u003cscript type = \"module\"\u003e\n  import { IndefiniteObservable } from \"https://ajax.googleapis.com/ajax/libs/indefinite-observable/2.0.1/indefinite-observable.bundle.js\"\n\u003c/script\u003e\n```\n\n## Contributing ##\n\nThis library aims to be as simple as possible, so modifications will be rare.  Reasons we might make changes are limited to:\n\n- bugs, or\n- remaining compatible with the subset of the Observable spec that we support.\n\nIf you'd like to add operators, static methods, or other features, we invite you to depend upon us subclassing `IndefiniteObservable` in your own module.  In fact, [that's how we add features too](https://github.com/material-motion/material-motion-js/blob/develop/packages/core/src/observables/MotionObservable.ts).\n\nOf course, we welcome improvements to the examples and documentation in this repo.\n\n### Bundling ###\n\nOur source is available in 3 flavors: a TypeScript module, a JavaScript module, and a JavaScript bundle.  Any changes made to the first need to be reflected in the other two.  This should be handled for you automatically via a pre-commit hook.  If you have a clean working copy after committing, you're good.  If not, amend the commit with the new build before pushing.\n\nIf you need to bundle it independently, run\n\n```\nyarn run build\n```\n\n### Testing ###\n\n```\nyarn run test\n```\n\n## License ##\n\n[Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaterial-motion%2Findefinite-observable-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaterial-motion%2Findefinite-observable-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaterial-motion%2Findefinite-observable-js/lists"}