{"id":21811478,"url":"https://github.com/dnbard/knockout.getset","last_synced_at":"2025-03-21T09:15:16.199Z","repository":{"id":26524653,"uuid":"29977644","full_name":"dnbard/knockout.getset","owner":"dnbard","description":"Another way to bind observables for Knockout","archived":false,"fork":false,"pushed_at":"2015-01-31T12:05:40.000Z","size":136,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-26T06:12:37.346Z","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/dnbard.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":"2015-01-28T16:51:10.000Z","updated_at":"2023-07-27T04:08:10.000Z","dependencies_parsed_at":"2022-08-20T18:50:50.916Z","dependency_job_id":null,"html_url":"https://github.com/dnbard/knockout.getset","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnbard%2Fknockout.getset","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnbard%2Fknockout.getset/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnbard%2Fknockout.getset/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dnbard%2Fknockout.getset/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dnbard","download_url":"https://codeload.github.com/dnbard/knockout.getset/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244767798,"owners_count":20507110,"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-27T13:44:48.748Z","updated_at":"2025-03-21T09:15:16.173Z","avatar_url":"https://github.com/dnbard.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"#knockout.getset\n\nSimple library to start using `this.property = true;` instead of `this.property(true);` for observables in [Knockout](https://github.com/knockout/knockout).\n\n##Installation\n\nInstall from `bower`:\n\n```bash\nbower install knockout-getset --save\n```\n\nor `npm`:\n\n```bash\nnpm install knockout.getset --save\n```\n\n##Compatibility\nInternet Explorer 9+ and literaly anything else. For more information [consult this table](http://kangax.github.io/compat-table/es5/#Getter_in_property_initializer).\n\n##Documentation\n\n###Observable\nTo define an observable you need:\n```js\nvar viewmodel = {}, initialValue = 1;\nko.gsObservable(viewmodel, 'observableProperty', initialValue);\n```\n\nThen `observableProperty` will be available to modification in `viewModel` object:\n\n```js\nviewmodel.observableProperty = 1;\nviewmodel.observableProperty; //1\n\nviewmodel.observableProperty = 5;\nviewmodel.observableProperty; //5\n```\n\nIf you want to register your own subscriptions with `gsObservable`:\n\n```js\nko.gsObservable(viewModel, 'observableProperty', initialValue)\n    .subscribe(function(newValue){\n        console.log('I\\'ve been changed to %s', newValue);\n    });\n\nviewmodel.observableProperty = 5;\n//I've been changed to 5\n```\n\n###Observable Array\nTo define an observable array you need:\n```js\nko.gsObservableArray(viewmodel, 'observableArray');\n\nviewmodel.observableArray; //[]\n```\n\n###Computed\nTo define a computed you need:\n```js\nko.gsComputed(viewmodel, 'computed', function(){\n    return 'I\\'m computed!';\n});\n\nviewmodel.computed; //\"I'm computed!\"\n```\n\nExample on using of computed with observables:\n```js\nko.gsObservable(viewmodel, 'name', 'Peter Griffin');\n\nko.gsComputed(viewmodel, 'title', function(){\n    return 'Mr. ' + this.name;\n});\n\nviewmodel.title; \"Mr. Peter Griffin\"\n\nviewmodel.name = 'Brian Griffin';\nviewmodel.title; \"Mr. Brian Griffin\"\n```\n\n###Simple objects\nSince there is no observables in viewmodel then we can simply skip a 'ko.toJS' or any other unwrap routine. In example:\n```js\nko.gsObservable(viewmodel, 'name', 'Peter Griffin');\n\nko.gsComputed(viewmodel, 'title', function(){\n    return 'Mr. ' + this.name;\n});\n\nJSON.stringify(viewmodel);\n//'{ \"name\":\"Peter Griffin\", \"title\":\"Mr. Peter Griffin\" }'\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdnbard%2Fknockout.getset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdnbard%2Fknockout.getset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdnbard%2Fknockout.getset/lists"}