{"id":20409094,"url":"https://github.com/tcorral/observable-it","last_synced_at":"2025-12-12T04:24:03.300Z","repository":{"id":57313144,"uuid":"60900844","full_name":"tcorral/observable-it","owner":"tcorral","description":"Implementation of Observable pattern for browser","archived":false,"fork":false,"pushed_at":"2016-06-11T11:27:28.000Z","size":14,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-12T00:39:32.747Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tcorral.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-06-11T09:51:35.000Z","updated_at":"2016-09-17T07:31:59.000Z","dependencies_parsed_at":"2022-09-20T23:21:29.564Z","dependency_job_id":null,"html_url":"https://github.com/tcorral/observable-it","commit_stats":null,"previous_names":["tcorral/observable"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tcorral/observable-it","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcorral%2Fobservable-it","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcorral%2Fobservable-it/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcorral%2Fobservable-it/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcorral%2Fobservable-it/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tcorral","download_url":"https://codeload.github.com/tcorral/observable-it/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tcorral%2Fobservable-it/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265485021,"owners_count":23774419,"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":[],"created_at":"2024-11-15T05:39:34.364Z","updated_at":"2025-12-12T04:24:03.259Z","avatar_url":"https://github.com/tcorral.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# observable-it\n\n[![NPM Version](http://img.shields.io/npm/v/observable-it.svg?style=flat)](https://npmjs.org/package/observable-it)\n[![Build Status](http://img.shields.io/travis/tcorral/observable-it.svg?style=flat)](https://travis-ci.org/tcorral/observable-it)\n\nobservable-it is a library to implement Observable Design Pattern in Browser\nthat only relays on top of the Event Browser API without implementing anything new\nand most important without loops.\n\n## Installation\n\n### Node \n\nDependencies:\n\n* node \u003e= 0.10\n* npm \u003e= 2.0.0\n\n```bash\nnpm install observable-it --save\n```\n\n### Bower \n\n```bash\nbower install observable-it --save\n```\n\n## Usage\n\n### API:\n\n#### Require:\n\n```js\nimport Observer from './path/to/observable.js';\n```\n\n#### Constructor:\n\n```js\nimport Observer from './path/to/observable.js';\n\nvar observer = new Observer();\n``` \n\n#### Subscribe:\n\n```js\nimport Observer from './path/to/observable.js';\n\nvar observer = new Observer();\n\nobserver.subscribe('my-event', function (event) {\n    console.log('My Event is triggered');\n});\n``` \n\n#### Publish without passing data:\n\n```js\nimport Observer from './path/to/observable.js';\n\nvar observer = new Observer();\n\nobserver.subscribe('my-event', function (event) {\n    console.log('My Event is triggered');\n});\n\nobserver.publish('my-event');\n``` \n\n#### Publish passing data:\n\n```js\nimport Observer from './path/to/observable.js';\n\nvar observer = new Observer();\n\nobserver.subscribe('my-event', function (event) {\n    console.log('Data from publish:', event.detail);\n});\n\nobserver.publish('my-event', { data: 'data-for-my-event' });\n``` \n\n#### Publishing before subscribe:\nobservable-it will queue all the events when there is no subscribers to that event \nand when publish is done for this event, that event will be triggered.\n\n```\nYou will never lose an event.\n```\n\n```js\nimport Observer from './path/to/observable.js';\n\nvar observer = new Observer();\n\nobserver.publish('my-event', { data: 'data-for-my-event' });\n\nobserver.subscribe('my-event', function (event) {\n    console.log('Data from publish:', event.detail);\n});\n``` \n\n## Extending:\nobservable-it has been designed to extend from it as well, so that you\ncan easily convert your objects in observable objects too.\n\n### Extending:\n```js\nimport Observer from './path/to/observable.js';\n\nclass MyConstructor extends Observer {\n    constructor() {\n        super();\n    }\n}\n\nexport default MyConstructor;\n``` \n\n\nTo get more information I recommend to read the use cases in tests.\n\n## Tests\n\nTo run the tests with QUnit:\n\n```bash\nnpm install\nnpm test\n```\n\n## Contributing\n\n1. Fork it!\n2. Create your feature branch: `git checkout -b my-new-feature`\n3. Install jspm\n```js\nnpm install -g jspm\n```\n4. Commit your changes: `git commit -am 'Add some feature'`\n5. Check that it still works: `npm test`\n6. Push to the branch: `git push origin my-new-feature`\n7. Submit a pull request :D\n\n## History\n\n0.1.0 - First release.\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2016 Tomás Corral\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftcorral%2Fobservable-it","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftcorral%2Fobservable-it","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftcorral%2Fobservable-it/lists"}