{"id":19701412,"url":"https://github.com/frontendmasters/observablish-values","last_synced_at":"2025-04-29T13:33:09.023Z","repository":{"id":189386326,"uuid":"680583228","full_name":"FrontendMasters/observablish-values","owner":"FrontendMasters","description":null,"archived":false,"fork":false,"pushed_at":"2023-08-19T18:08:17.000Z","size":3,"stargazers_count":25,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-05T17:36:16.177Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FrontendMasters.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-08-19T18:02:55.000Z","updated_at":"2024-07-27T18:09:52.000Z","dependencies_parsed_at":"2023-08-19T19:25:10.857Z","dependency_job_id":"4a192c9f-b5c8-402c-bb3a-27ac0c38a497","html_url":"https://github.com/FrontendMasters/observablish-values","commit_stats":null,"previous_names":["frontendmasters/observablish-values"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FrontendMasters%2Fobservablish-values","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FrontendMasters%2Fobservablish-values/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FrontendMasters%2Fobservablish-values/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FrontendMasters%2Fobservablish-values/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FrontendMasters","download_url":"https://codeload.github.com/FrontendMasters/observablish-values/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251509853,"owners_count":21600713,"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-11T21:08:49.697Z","updated_at":"2025-04-29T13:33:08.742Z","avatar_url":"https://github.com/FrontendMasters.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# An Observable-ish Value\n\nPublish changes to subscriber functions when values change.\n\n```javascript\nconst fn = function(current, previous) {}\n\nconst obsValue = ov('initial');\nobsValue.subscribe(fn);      // subscribe to changes\nobsValue();                  // 'initial'\nobsValue('initial');         // identical value, no change\nobsValue('new');             // fn('new', 'initial')\nobsValue.value = 'silent';   // silent update\n```\n\nModifying arrays and objects will not publish, but replacing them will.\n\n```javascript\nconst obsArray = ov([1, 2, 3]);\nobsarray().subscribe(fn);\nobsArray().push(4);          // silent update\nobsArray.publish();          // fn([1, 2, 3, 4]);\nobsArray([4, 5]);            // fn([4, 5], [1, 2, 3]);\n```\n\nPassing a function caches the result as the value. Any extra arguments will\nbe passed to the function. Any observables called within the function will\nbe subscribed to, and updates to those observables will recompute the value.\nChild observables must be called, mere references are ignored. If the\nfunction returns a Promise, the value is assigned async after resolution.\n\n```javascript\nconst a = ov(1);\nconst b = ov(2);\nconst computed = ov(arg =\u003e { a() + b() + arg }, 3);\ncomputed.subscribe(fn);\ncomputed();                  // fn(6)\na(2);                        // fn(7, 6)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrontendmasters%2Fobservablish-values","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrontendmasters%2Fobservablish-values","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrontendmasters%2Fobservablish-values/lists"}