{"id":23391914,"url":"https://github.com/yuraxdrumz/certiorem","last_synced_at":"2026-05-18T09:35:57.030Z","repository":{"id":57196163,"uuid":"99260133","full_name":"yuraxdrumz/certiorem","owner":"yuraxdrumz","description":"an implementation of the observer pattern in node.js using object composition and concatenative inheritance","archived":false,"fork":false,"pushed_at":"2017-08-07T20:00:33.000Z","size":44,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-09-16T15:43:32.103Z","etag":null,"topics":["event-emitter","nodejs","observer-pattern"],"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/yuraxdrumz.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":"2017-08-03T17:49:09.000Z","updated_at":"2021-08-13T05:00:09.000Z","dependencies_parsed_at":"2022-09-16T12:12:46.674Z","dependency_job_id":null,"html_url":"https://github.com/yuraxdrumz/certiorem","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/yuraxdrumz/certiorem","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuraxdrumz%2Fcertiorem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuraxdrumz%2Fcertiorem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuraxdrumz%2Fcertiorem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuraxdrumz%2Fcertiorem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yuraxdrumz","download_url":"https://codeload.github.com/yuraxdrumz/certiorem/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuraxdrumz%2Fcertiorem/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33172708,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-18T09:27:30.708Z","status":"ssl_error","status_checked_at":"2026-05-18T09:27:28.300Z","response_time":71,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["event-emitter","nodejs","observer-pattern"],"created_at":"2024-12-22T04:27:50.362Z","updated_at":"2026-05-18T09:35:56.998Z","avatar_url":"https://github.com/yuraxdrumz.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# certiorem\nAn implementation of the observer pattern in node.js with event emitter.\n0 dependencies and usage is very straight forward and declarative.\n## Usage\nyou have two functions in certiorem, one is called `createObservable` and the other is called `createObserver`.\n`createObservable` creates a new instance of a parent class that will hold all the observers and notify them on events emitted, the `createObserver` creates a new instance of an observer that will talk directly to the observable instance.\nyou can have as many observables as you want and for each observable you can have as many observers as you want\n\n# 1.0.32 features\n`added makeObservable and makeObserver decorators to extend existing classes`\nyou can now extend your class to be an observable or an observer and even share listeners with other observables\n```javascript\nimport { makeObservable, makeObserver, createObservable, createObserver } from 'certiorem'\n\nlet observableExample = createObservable()\n\n// makeObservable can decorate classes in order to make them subjects that observers can subscribe to\n// excepts two args(optional observable, bool-share listeners if first arg passed)\n@makeObservable()\nclass ToBeObservable {\n  eat(){\n    console.log('im eating...')\n  }\n}\n// any instance of ToBeObservable will have emit now...\nlet instance = new ToBeObservable()\n\n// makeObserver decorates a class to be an observer\n// this decorator excepts two args(name, observableToAttachTo)\n// you can pass both an instance created by your decorated class or an instance created by the createObservable func\n@makeObserver('observer1', instance)\nclass ToBeObserver{\n  sleep(){\n    console.log('im sleeping...')\n  }\n}\nlet decoratedObserver = new ToBeObserver()\ndecoratedObserver.subscribe('boom', data =\u003e console.log(data)\ninstance.emit('boom', 'here comes the boom')\n// outputs here comes the boom\n```\n\nFirst, install the package using npm:\n`npm install certiorem --save`\nThen, require it and use it like so:\n![image of require](http://i.imgur.com/aWrEgJW.png)\n## Observable methods\n# emit\n`the emit method receives the event name as the first argument and all arguments that come after are passed to all listeners subscribed`\n```javascript\nimport { createObservable, createObserver } from 'certiorem'\nlet mainObservable = createObservable()\nmainObservable.emit('start')\n```\n## Observer methods\n`Observer receives two arguments, the first is the observers name, the second is the Observable to attach to, so that all subscribtions will listen to events emitted by that Observable`\n`The example below shows how two listeners are added to the mainObservable instance, all emitted events will pass to them if they are subscribed`\n```javascript\nimport { createObservable, createObserver } from 'certiorem'\nlet mainObservable = createObservable()\nlet listener1 = createObserver('listener1', mainObservable)\nlet listener2 = createObserver('listener2', mainObservable)\n```\n# subscribe\n`subscribe receives two arguments, the first one is the event name to subscribe to and the second is a function that receives arguments`\n`here you can see that listener1 is subscribed to the start event and its handler is a function that receives data and logs it to the console`\n```javascript\nimport { createObservable, createObserver } from 'certiorem'\nlet mainObservable = createObservable()\nlet listener1 = createObserver('listener1', mainObservable)\nlistener1.subscribe('start', function(data){\n    console.log(data)\n})\nmainObservable.emit('start', 'this string will be passed down to all listeners of the start event')\n```\n# unsubscribe\n`the unsubscribe method removes the current listener from a specific event`\n```javascript\nimport { createObservable, createObserver } from 'certiorem'\nlet mainObservable = createObservable()\nlet listener1 = createObserver('listener1', mainObservable)\nlet listener2 = createObserver('listener2', mainObservable)\nlistener1.subscribe('start', function(data){\n    console.log(data)\n})\nlistener2.subscribe('start', function(data){\n    console.log(data)\n})\nlistener1.unsubscribe('start')\nmainObservable.emit('start')\n// only listener2 will respond to this event\n```\n# emit\n`the observers emit method allows an observer to dispatch an event to the parent he his attached to, the mainObservable in this example and the mainObservable automatically dispatches the event to all listeners attached`\n```javascript\nimport { createObservable, createObserver } from 'certiorem'\nlet mainObservable = createObservable()\nlet listener1 = createObserver('listener1', mainObservable)\nlet listener2 = createObserver('listener2', mainObservable)\nlistener1.subscribe('start', function(data){\n    console.log(data)\n})\nlistener2.subscribe('start', function(data){\n    console.log(data)\n})\n// this emit is similar to the parent emit, except it emits to the parent, and the parent automatically emits the event to all listeners\nlistener1.emit('start', 'started in listener1')\n```\n\n\nFirst, install the package using npm:\n`npm install certiorem --save`\nThen, require it and use it like so:\n![image of require](http://i.imgur.com/aWrEgJW.png)\n## Observable methods\n# emit\n`the emit method receives the event name as the first argument and all arguments that come after are passed to all listeners subscribed`\n```javascript\nimport { createObservable, createObserver } from 'certiorem'\nlet mainObservable = createObservable()\nmainObservable.emit('start')\n```\n## Observer methods\n`Observer receives two arguments, the first is the observers name, the second is the Observable to attach to, so that all subscribtions will listen to events emitted by that Observable`\n`The example below shows how two listeners are added to the mainObservable instance, all emitted events will pass to them if they are subscribed`\n```javascript\nimport { createObservable, createObserver } from 'certiorem'\nlet mainObservable = createObservable()\nlet listener1 = createObserver('listener1', mainObservable)\nlet listener2 = createObserver('listener2', mainObservable)\n```\n# subscribe\n`subscribe receives two arguments, the first one is the event name to subscribe to and the second is a function that receives arguments`\n`here you can see that listener1 is subscribed to the start event and its handler is a function that receives data and logs it to the console`\n```javascript\nimport { createObservable, createObserver } from 'certiorem'\nlet mainObservable = createObservable()\nlet listener1 = createObserver('listener1', mainObservable)\nlistener1.subscribe('start', function(data){\n    console.log(data)\n})\nmainObservable.emit('start', 'this string will be passed down to all listeners of the start event')\n```\n# unsubscribe\n`the unsubscribe method removes the current listener from a specific event`\n```javascript\nimport { createObservable, createObserver } from 'certiorem'\nlet mainObservable = createObservable()\nlet listener1 = createObserver('listener1', mainObservable)\nlet listener2 = createObserver('listener2', mainObservable)\nlistener1.subscribe('start', function(data){\n    console.log(data)\n})\nlistener2.subscribe('start', function(data){\n    console.log(data)\n})\nlistener1.unsubscribe('start')\nmainObservable.emit('start')\n// only listener2 will respond to this event\n```\n# emit\n`the observers emit method allows an observer to dispatch an event to the parent he his attached to, the mainObservable in this example and the mainObservable automatically dispatches the event to all listeners attached`\n```javascript\nimport { createObservable, createObserver } from 'certiorem'\nlet mainObservable = createObservable()\nlet listener1 = createObserver('listener1', mainObservable)\nlet listener2 = createObserver('listener2', mainObservable)\nlistener1.subscribe('start', function(data){\n    console.log(data)\n})\nlistener2.subscribe('start', function(data){\n    console.log(data)\n})\n// this emit is similar to the parent emit, except it emits to the parent, and the parent automatically emits the event to all listeners\nlistener1.emit('start', 'started in listener1')\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuraxdrumz%2Fcertiorem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyuraxdrumz%2Fcertiorem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuraxdrumz%2Fcertiorem/lists"}