{"id":25601388,"url":"https://github.com/magnusthor/thor-rx","last_synced_at":"2025-11-11T03:31:34.702Z","repository":{"id":143918741,"uuid":"85828305","full_name":"MagnusThor/thor-rx","owner":"MagnusThor","description":"ThorRx is a tiny Proxy based lib for deliverering events and change records to keep track of mutations.","archived":false,"fork":false,"pushed_at":"2017-04-10T11:41:30.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-05T09:38:54.529Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MagnusThor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-03-22T13:02:09.000Z","updated_at":"2017-03-22T13:21:16.000Z","dependencies_parsed_at":"2023-05-28T07:45:37.668Z","dependency_job_id":null,"html_url":"https://github.com/MagnusThor/thor-rx","commit_stats":{"total_commits":7,"total_committers":1,"mean_commits":7.0,"dds":0.0,"last_synced_commit":"21525691f2407e5236fde06a4805e37eeb27c3e5"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MagnusThor%2Fthor-rx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MagnusThor%2Fthor-rx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MagnusThor%2Fthor-rx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MagnusThor%2Fthor-rx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MagnusThor","download_url":"https://codeload.github.com/MagnusThor/thor-rx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240045013,"owners_count":19739184,"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":"2025-02-21T15:54:24.029Z","updated_at":"2025-11-11T03:31:34.348Z","avatar_url":"https://github.com/MagnusThor.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# thor-rx\nThorRx is a tiny Proxy based lib for\ndeliverering events and change records to keep track of mutations on objects (models).\nWhen a property is modified on an thor-rx 'observed' instance \nthor-rx will deliver change notifications \nthat helps you keep track of changes in a smooth way.\n\n## Installation\n\n    npm install thor-rx\n\n\n# Documentation\n\nBelow follows a brief documentation.\n\n## ThorRx\u0026lt;T extends ThorRxBase \u0026gt;(obj:any, (changes:ChangeModel) =\u003evoid):ThorRx\u0026lt;T\u0026gt;\n\nCreate a new thor-rx observer\n\n    let rx = new ThorRx\u003cT\u003e(instance,(changes:ChangeModel) =\u003e {}); \n\n### getObserver():T\n\nGet a thor-rx instance of type T.  T is the proxied instances of yours. \n\n    observerOfT = rx.getObserver();\n\n\n #### example\n\n Where we have an object(Model) Person \n\n      let person = new Person();\n\n      let rx = new ThorRx\u003cT\u003e(person , (changes:ChangeModel) =\u003e {\n            // do op with changes\n      }); \n\n      let rxPerson= rx.getObserver();\n\n      // rx person is now a observed (Proxied) instance of Person\n\n\n## ChangeModel\n\nChange model contains information about the current change.\n\n    class ChangeModel {\n        target: any;\n        type: string;\n        newValue: any;\n        oldValue: any;\n        timeStamp: Date;\n        constructor(target: any, type: string, newValue: any, oldValue: any);\n        }\n\n### Change type's\n\nAn change type can be as follows: add, removed and update.  \nadd and remove relates to Array properties. \n\n\n## ThorRxBase\n\nThe objects you wich to observe must derive (extends) from \nThorRxBase.\n\n     class MyModel extends ThorRxBase{\n         constructor(){\n             super(); \n             ..\n         }\n     }\n\n### observe(target:any) : void\n\nMake an property / target of the class that derives from ThorRxBase \nan observable. Will report changes when modified\n\n### unobserve(target:any): void \n\nMakes a properry ( target) a non observable. Will not report changes when modified\n\n\n\n# Decorators\n\nDecorators lets you by decorating properties of your objects(classes)\ngain control of what attributes that thor-rx captures mutations on.\nBy default the property is observed.\n\n### @Observe(isObserve:boolean)\n\nif an @Observe decorator exists on a property , you can control it\nby settig isObserve:boolean to true/false, if fn:Function is\ndefined fn will be the Fn to be called on property mutations.\n\nNote: will not affect newable properties. See observe and unobserve above.\n\n#### example\n\n    class Person{\n\n        @Observe(false) fullName:string;\n        @Observe(true) age:number\n        ...\n    }\n\n# Example ( Quick guide )\n\nThe example below creates an thor-rx observer for Person (class) \n\n    let personObserver = new ThorRx\u003cPerson\u003e(new Person(), (change:ChangeModel) =\u003e {\n         // do op's with the change\n    }); \n\nWhere person look needs to extend ThorRxBase such as\n\n    class Person extends ThorRxBase {\n        fullName:string\n        constructor(){\n            super();\n        }\n    }    \n\nTo get an observer instance you need to call .getObserver():T such as below.\n\n    let personObserver = new ThorRx\u003cPerson\u003e(new Person(),(change:ChangeModel) =\u003e {\n        // do op's with the change\n    });\n\n    let person =  personObserver.getObserver()\n\n    person.fullName = \"Sven Erik Magnusson\";\n\nSetting the property .fullName will deliver (fire) the changes \nhandler you provded , in this example \n\n    (change:ChangeModel) =\u003e {\n\n        // do op\n\n    }\n\n# Roadmap / Todo\n\n    -\n\n    \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagnusthor%2Fthor-rx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagnusthor%2Fthor-rx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagnusthor%2Fthor-rx/lists"}