{"id":17713735,"url":"https://github.com/duart38/observe","last_synced_at":"2025-08-20T11:28:13.929Z","repository":{"id":130906632,"uuid":"283024570","full_name":"duart38/Observe","owner":"duart38","description":"Type-safe observable values (made with Deno)","archived":false,"fork":false,"pushed_at":"2021-03-16T14:55:58.000Z","size":251,"stargazers_count":14,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-09-16T15:08:12.661Z","etag":null,"topics":["binding","deno","deno-module","denoland","event","history","javascript","javascript-library","livedata-databinding","minimal","no-dependencies","observable","observer","state","state-management","state-pattern","typesafe","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/duart38.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["duart38"]}},"created_at":"2020-07-27T21:48:43.000Z","updated_at":"2023-09-05T08:50:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"8bc645a0-565d-46a7-85df-be23bd2a4e5a","html_url":"https://github.com/duart38/Observe","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duart38%2FObserve","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duart38%2FObserve/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duart38%2FObserve/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duart38%2FObserve/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/duart38","download_url":"https://codeload.github.com/duart38/Observe/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249991150,"owners_count":21357208,"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":["binding","deno","deno-module","denoland","event","history","javascript","javascript-library","livedata-databinding","minimal","no-dependencies","observable","observer","state","state-management","state-pattern","typesafe","typescript"],"created_at":"2024-10-25T10:22:21.563Z","updated_at":"2025-04-21T03:32:28.547Z","avatar_url":"https://github.com/duart38.png","language":"TypeScript","funding_links":["https://github.com/sponsors/duart38"],"categories":[],"sub_categories":[],"readme":"![alt text](https://raw.githubusercontent.com/duart38/Observe/master/banner.svg \"Logo Title Text 1\")\n# Observe\n\u003e **Simply observe any variable** \u003cbr\u003e\n\n\u003e ![Test module](https://github.com/duart38/Observe/workflows/Test%20module/badge.svg?branch=master)  \n[![nest badge](https://nest.land/badge.svg)](https://nest.land/package/Observe)\n\n\n## Example (Deno)\n```JavaScript\nlet obs = new Observe(\"initial value\"); // new observable with type String\n\nobs.bind((data) =\u003e { // bind to receive updates on value change\n    // Do some stuff here (data here is of type string)\n});\n\nobs.setValue(\"another value\"); // sets the value\nobs.setValue(\"lorem\", \"ipsum\", \"dolor\"); // sets the last value as active and emitting the other ones\nconsole.log(obs.setValue(\"another value\"))\n```\nAlso check the examples folder for more examples\n\n## Example (Basic html + js)\n\u003e Download Observe.js from the releases tab\n\n**index.html**\n```html\n\u003chtml\u003e\n    \u003chead\u003e\u003c/head\u003e\n    \u003cbody\u003e\n        \u003ch1\u003eObservable value test\u003c/h1\u003e\n        \u003cscript type=\"module\" src=\"Observe.bundle.js\"\u003e\u003c/script\u003e \u003c!-- Needs to come from a server as type module does not support local files--\u003e\n        \u003cscript src=\"./index.js\"\u003e\u003c/script\u003e\n    \u003c/body\u003e\n\u003c/html\u003e\n```\n\n**index.js**\n```JavaScript\nvar observable = new Observe(\"s\")\nobservable.bind((d)=\u003e{\n    console.log(d)\n})\nobservable.setValue(\"new val\")\n```\n## Methods\n\n---\n\n| Name           \t| Description                                                                                                                                                                                                                 \t|\n|----------------\t|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\t|\n| getValue()     \t| Returns the current value. To be used outside of callbacks                                                                                                                                                                  \t|\n| getHistory()   \t| Gets the change history. Every time a new value is set it is pushed to a history array                                                                                                                                      \t|\n| bind()         \t| used to listen to changes. Takes a callback method that is called with the new data when the observe instance changes. **Returns the function used for the event listener.. To be used with the unBind method (see below)** \t|\n| unBind()       \t| Unbinds a previously bound EventListener or EventListenerObject. The callback returned by bind() should be provided. Returns this                                                                                           \t|\n| setValue()     \t| Updates the observed value.. all bound will be notified. Setting a value equals to the last set value will do nothing. Returns the value that was passed in it (last value in case multiple)                                \t|\n| stop()         \t| Prevents event from reaching any registered event listeners after the current one. Returns this                                                                                                                             \t|\n| reset()        \t| Restore the state to the original provided method. Returns this                                                                                                                                                             \t|\n| unBindAll()    \t| Unbinds ALL previously bound EventListener or EventListenerObject.                                                                                                                                                          \t|\n| maxHistorySize \t| Limit the history array size **(can be lowered to save some precious ram)**                                                                                                                                                 \t|\n| getGlobalObservable \t| If opted in, receives the instance created that was attached to the JS window                                                                                                                                                \t|\n\n\n\u003e The history length is limited to 1000 values.. after this the first value (excluding the original) will be removed on each push.. to increase or decrease this value change the \"maxHistorySize\" variable\n\nSee JSdoc for more information\n\n### It is recommended to lower the value of maxHistorySize if you are not going to use the history.\n\n## Testing\n```Shell\ndeno test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fduart38%2Fobserve","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fduart38%2Fobserve","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fduart38%2Fobserve/lists"}