{"id":22916427,"url":"https://github.com/code0wl/frequency","last_synced_at":"2025-04-01T12:43:35.809Z","repository":{"id":57241734,"uuid":"61063235","full_name":"code0wl/frequency","owner":"code0wl","description":":radio: A plug and play PubSub system that just works as if it were an FM radio","archived":false,"fork":false,"pushed_at":"2016-06-19T19:37:06.000Z","size":46,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-17T17:19:59.334Z","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/code0wl.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-06-13T19:18:33.000Z","updated_at":"2019-10-19T01:47:20.000Z","dependencies_parsed_at":"2022-09-07T23:13:28.706Z","dependency_job_id":null,"html_url":"https://github.com/code0wl/frequency","commit_stats":null,"previous_names":["code0wl/broadcaster"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code0wl%2Ffrequency","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code0wl%2Ffrequency/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code0wl%2Ffrequency/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code0wl%2Ffrequency/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/code0wl","download_url":"https://codeload.github.com/code0wl/frequency/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246586050,"owners_count":20801026,"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-14T06:12:47.988Z","updated_at":"2025-04-01T12:43:35.781Z","avatar_url":"https://github.com/code0wl.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Frequency-wave \n\u003cimg src=\"src/radio.jpg\"\u003e \u003cbr\u003e\nA plug and play PubSub system that just works as if it were an FM radio :)))\n\n### Why another publish and subscribe pattern you ask?\nSimply because creating custom events that get fired syntactically in the browser is a very handy pattern. With thousands of implementations out in the wild and still it wasn't clear to see which one was memory conservative (this could be my own short-sidedness). Conserving memory is extremely important depending on how complex your application state is. Frequency wave focuses clearly on just that. Allowing you to remove name-spaced events so you do not pollute your own global scopes with unnecessary memory usage.\n\n### Solution\nOn of the solutions to this problem is to include a system that gives the developer the ability to flush out stations (transmitters).\n\n### Usage in the browser\nInclude the minified js file from npm by installing from npm repository and importing it in your build tool\n```\nnpm i -S frequency-wave\n```\n\n####API (consider the following sequence and comments)\n```\n/*\n* @param string station is the current namespace for your event\n* @param string tuner the identifier for your event\n* @wave object for the object you are passing\n*/\nfrequency.tuneIn(station, tuner, wave);\n\n\n/*\n* @param string station the current namespace for your event\n* @param string tuner the identifier for your event\n*/\nfrequency.transmit(station, 'Alarm');\n\n\n/*\n* @param string station is the current namespace for your event\n* @param string tuner the identifier for your event\n*/\nfrequency.tuneOut(station, tuner);\n\n\nfrequency.tuneIn('FM', 'Alarm', firstAlarm); // creates listener for Alarm for the FM station, runs callback firstAlarm\nfrequency.tuneIn('FM', 'Alarm2', firstAlarm); // creates listener for Alarm2 for the FM station, runs callback firstAlarm\nfrequency.tuneIn('FM', 'Alarm', secondAlarm); // creates listener for Alarm for the AM station, runs callback secondAlarm\n\nfrequency.transmit('FM', 'Alarm'); // broadcasts a global wave containing the station and frequency\nfrequency.transmit('FM', 'Alarm2'); // will trigger firstAlarm\n\nfrequency.tuneOut('FM', 'Alarm'); // tune out the first alarm frequency on the FM station\nfrequency.transmit('FM', 'Alarm'); // will no longer work\nfrequency.transmit('FM', 'Alarm2'); // will still work (benefit: you are name-spacing your Pubsub events)\n\nfrequency.shutDown('FM'); // Station gets destroyed, no channel is listened to anymore and memory released to be allocated somewhere else\n\nfunction firstAlarm() {\n    console.log('I run firstAlarm');\n}\n\nfunction secondAlarm() {\n    console.log('I run secondAlarm');\n}\n```\n\n### Usage for this product\nAnyone can contribute. The project is build on webpack.\nYou can get the project running with the following command\n```\nnpm start\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode0wl%2Ffrequency","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcode0wl%2Ffrequency","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode0wl%2Ffrequency/lists"}