{"id":22505413,"url":"https://github.com/azer/attr","last_synced_at":"2025-06-22T19:34:53.717Z","repository":{"id":7275707,"uuid":"8589454","full_name":"azer/attr","owner":"azer","description":"Observable Attributes","archived":false,"fork":false,"pushed_at":"2016-12-29T16:44:46.000Z","size":10,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T08:01:36.488Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/azer.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}},"created_at":"2013-03-05T21:24:19.000Z","updated_at":"2021-06-14T03:37:00.000Z","dependencies_parsed_at":"2022-09-07T19:21:08.891Z","dependency_job_id":null,"html_url":"https://github.com/azer/attr","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/azer/attr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azer%2Fattr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azer%2Fattr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azer%2Fattr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azer%2Fattr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/azer","download_url":"https://codeload.github.com/azer/attr/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azer%2Fattr/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261352442,"owners_count":23146056,"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-12-07T00:18:25.402Z","updated_at":"2025-06-22T19:34:48.684Z","avatar_url":"https://github.com/azer.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## attr [![Build Status](https://travis-ci.org/azer/attr.png)](https://travis-ci.org/azer/attr)\nDefine values that you can subscribe for changes. Based on [pubsub](http://github.com/azer/pubsub)\n\n```js\nmessage = attr('Hello World')\n\nmessage()\n// =\u003e Hello World\n\nmessage.subscribe(function (update, old) {\n  console.log(update, old)\n  // =\u003e 你好, Hello World\n})\n\nmessage('你好')\nmessage()\n// =\u003e 你好\n```\n\n## Install\n\n```bash\n$ npm install attr\n```\n\n## API\n\n### attr()\n\nCreates and returns a new attr.\n\n```js\nmessage = attr('Hello World')\nmessage()\n// =\u003e Hello World\n```\n\nTo get the value of an attr, call it with no parameters:\n\n```js\nmessage()\n// =\u003e Hello World\n```\n\nTo change the value of an attr, call the attr with new value:\n\n```js\nmessage('Foo Bar')\n\nmessage()\n// =\u003e Foo Bar\n```\n\n### #subscribe(`function`)\n\nSubscribes the given function to changes.\n\n```js\nmessage.subscribe(function () {\n\n  message()\n  // =\u003e Lorem Ipsum\n\n})\n\nmessage('Lorem Ipsum')\n```\n\n### #subscribe.once(`function`)\n\n### #unsubscribe(`function`)\n\n### #unsubscribe.once(`function`)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazer%2Fattr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fazer%2Fattr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazer%2Fattr/lists"}