{"id":24678948,"url":"https://github.com/evinism/stupid-subscribe","last_synced_at":"2026-04-15T22:31:39.363Z","repository":{"id":57373124,"uuid":"64197494","full_name":"evinism/stupid-subscribe","owner":"evinism","description":"Tiny JS snippet for an extremely simple, extremely stupid data subscriber.","archived":false,"fork":false,"pushed_at":"2017-09-12T21:49:15.000Z","size":5,"stargazers_count":3,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-03-30T09:21:11.348Z","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/evinism.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":"2016-07-26T06:53:57.000Z","updated_at":"2022-04-28T06:28:46.000Z","dependencies_parsed_at":"2022-08-30T00:40:15.152Z","dependency_job_id":null,"html_url":"https://github.com/evinism/stupid-subscribe","commit_stats":null,"previous_names":["evinism/stupidsubscribe"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/evinism/stupid-subscribe","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evinism%2Fstupid-subscribe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evinism%2Fstupid-subscribe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evinism%2Fstupid-subscribe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evinism%2Fstupid-subscribe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evinism","download_url":"https://codeload.github.com/evinism/stupid-subscribe/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evinism%2Fstupid-subscribe/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31863423,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T15:24:51.572Z","status":"ssl_error","status_checked_at":"2026-04-15T15:24:39.138Z","response_time":63,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":"2025-01-26T13:19:36.887Z","updated_at":"2026-04-15T22:31:39.348Z","avatar_url":"https://github.com/evinism.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# stupid-subscribe\nTiny JS snippet for an extremely simple, extremely stupid data subscriber.\n\n### API\nAPI consists of 2 stupid functions `subscribe` and `action`;\n\n`action: (fn) =\u003e (fn)` wraps a function and introduces the sole side effect of triggering all subscribed actions.\n\n`subscribe: (listenerFn, readFn)` subscribes `listenerFn` to all actions.\n\nWhenever a function wrapped with `action` is called, all subscribed listeners are called with the results of their read function, i.e. `listenerFn(readFn())` is called\n\n### Brief pseudocoded example:\n\nThis implements an `\u003ch1\u003e` that increments a counter when you click on it.\n\n```\n// index.jsx\nimport {subscribe} from 'stupid-subscribe';\nimport appInterface from './app.js';\nimport AppView from './appview.jsx';\n\nsubscribe(\n  (appProps) =\u003e {\n    render(\u003cAppView {...appProps} /\u003e);\n  },\n  app.getProps\n);\n\n```\n\n```\n// app.js\nimport {action} from 'stupid-subscribe';\n\nlet numTimes = 0;\n\nexport default {\n  getProps: () =\u003e ({\n    text: `Clicked ${numTimes} times`,\n    clickHeader: action(() =\u003e (numTimes++)),\n  }),\n};\n```\n\n```\n// index.jsx\nconst AppView = (props) =\u003e (\n  \u003carticle\u003e\n    \u003ch1 onClick={props.clickHeader}\u003eClick Here!\u003c/h1\u003e\n    {props.text}!\n  \u003c/article\u003e\n);\n\nexport default AppView;\n```\n\n### Motivation\nsomething something `left-pad`\n\n### Contributing\nPlease help expand the FAQ to unconscionable lengths.\n\nAlso address issues I guess, but that's secondary.\n\n### FAQ\n\u003e Does the API even deserve to be called an API? It's not really an interface, as much as it is ~6 lines of utility functions\n\n**— [@evinism](https://github.com/evinism)**\n\nNo, probably not, but I went to a hackathon once and the speaker said \"API\" a lot and I guess it stuck with me.\n\n\n\u003e Can't we modify it so that actions trigger certain subscriptions, rather than all subscriptions, always?\n\n**— [@evinism](https://github.com/evinism)**\n\nI don't want to rename the repo to SlightlyLessStupidSubscribe.\n\n\n\u003e Could I use this on something that's not stupid?\n\n**— [@evinism](https://github.com/evinism)**\n\nYes, I strongly encourage it. It falls directly in line with a quintessential software design principle of which I am a big proponent, namely:\n\n*Software should be an absolute trainwreck*\n\n\n\u003e Isn't this a dumbed down version of [x]?\n\n**— [@evinism](https://github.com/evinism)**\n\nYes, in the same way that everyone is a dumbed down version of Einstein, so too is this a dumbed down version of literally everything.\n\n\n\u003e Why doesn't subscribe just take a single function, and allow the user to just `compose(listenerFn, readFn)` themselves?\n\n**— [@evinism](https://github.com/evinism)**\n\nReasons: \n- I think it's an unnecessary abstraction. I want to enforce that semantic separation of a listener and a reader, I feel like it makes the dataflow easier to reason about.\n- I didn't think of it at first\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevinism%2Fstupid-subscribe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevinism%2Fstupid-subscribe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevinism%2Fstupid-subscribe/lists"}