{"id":18901137,"url":"https://github.com/regular/tre-watch-heads","last_synced_at":"2026-03-03T19:30:18.995Z","repository":{"id":57379460,"uuid":"158689035","full_name":"regular/tre-watch-heads","owner":"regular","description":null,"archived":false,"fork":false,"pushed_at":"2020-10-02T07:12:10.000Z","size":8,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-24T18:55:27.181Z","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/regular.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":"2018-11-22T11:25:27.000Z","updated_at":"2020-10-02T07:12:08.000Z","dependencies_parsed_at":"2022-09-02T21:22:01.742Z","dependency_job_id":null,"html_url":"https://github.com/regular/tre-watch-heads","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/regular%2Ftre-watch-heads","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/regular%2Ftre-watch-heads/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/regular%2Ftre-watch-heads/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/regular%2Ftre-watch-heads/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/regular","download_url":"https://codeload.github.com/regular/tre-watch-heads/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239886057,"owners_count":19713420,"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-08T08:55:18.790Z","updated_at":"2026-03-03T19:30:18.934Z","avatar_url":"https://github.com/regular.png","language":"JavaScript","readme":"tre-watch-heads\n---\nObserve mutable ssb messages\n\n``` js\nconst WatchHeads = require('tre-watch-heads')\nconst h = require('mutant/html-element')\nconst computed = require('mutant/computed')\n\n// pass your ssb client instance\nconst head = WatchHeads(ssb)\n\n// head() takes a revisionRoot and returns a mutant-compatible observable\n// This is how you get the revisionRoot from any ssb message, mutated or not\nconst revRoot = kv.value.content.revisionRoot || kv.key\n\n// html will update in realtime whenever we receive a new revision of this particular message\ndocument.body.appendChild(\n  h('div', [\n    h('div', 'latest version:'),\n    computed(head(revRoot), kvm =\u003e {\n      // 'kvm' stands for key/value/meta\n      const text = kvm \u0026\u0026 kvm.value.content.text\n      const isForked = kvm \u0026\u0026 kvm.meta.forked\n      return [\n        h('span', isForked ? 'forked' : 'not forked'),\n        h('div', text)\n      ]\n    })\n  ])\n)\n\n// When the element is removed from the dom, the underlying pull-stream\n// will be aborted automatically\n\n```\n\nSee Also:\n\n- [ssb-revisions](https://www.npmjs.com/package/ssb-revisions)\n- [mutant](https://www.npmjs.com/package/mutant)\n- [collect-mutations](https://www.npmjs.com/package/collect-mutations)\n\nLicense: ISC\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fregular%2Ftre-watch-heads","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fregular%2Ftre-watch-heads","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fregular%2Ftre-watch-heads/lists"}