{"id":21198099,"url":"https://github.com/retailmenot/ember-heisenberg","last_synced_at":"2025-07-10T05:32:26.974Z","repository":{"id":57223878,"uuid":"21138693","full_name":"RetailMeNot/ember-heisenberg","owner":"RetailMeNot","description":"Simple REST-like serialization and transport framework for Ember.js applications","archived":false,"fork":false,"pushed_at":"2014-07-19T16:58:30.000Z","size":671,"stargazers_count":4,"open_issues_count":1,"forks_count":3,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-11-09T06:11:22.210Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RetailMeNot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-06-23T19:08:04.000Z","updated_at":"2017-09-23T15:32:07.000Z","dependencies_parsed_at":"2022-08-30T02:10:26.159Z","dependency_job_id":null,"html_url":"https://github.com/RetailMeNot/ember-heisenberg","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RetailMeNot%2Fember-heisenberg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RetailMeNot%2Fember-heisenberg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RetailMeNot%2Fember-heisenberg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RetailMeNot%2Fember-heisenberg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RetailMeNot","download_url":"https://codeload.github.com/RetailMeNot/ember-heisenberg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225622934,"owners_count":17498168,"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-20T19:47:59.686Z","updated_at":"2024-11-20T19:48:00.381Z","avatar_url":"https://github.com/RetailMeNot.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ember-Heisenberg ![Build Status](https://travis-ci.org/RetailMeNot/ember-heisenberg.png?branch=master)\n\nEmber-Heisenberg is a simple REST-like serialization and transport framework for\nEmber.js applications. At its core, it provides a fluent, customizable,\npromise-oriented API to define and bind client-side models to server-side\nendpoints. Heisenberg is server-agnostic, which allows it to be flexible and\nconfigurable without sacrificing simplicity. It also means that Heisenberg\nplays well outside of a strict REST environment, and can just as easily support\nRPC-oriented endpoints.\n\n\n## Key Benefits\n\n- Lightweight: client-side model definitions are simple `Ember.Object` wrappers\n- Decoupled architecture: create a `Resource` definition to specify transport details\n- No 'magic': be as explicit as necessary about server-side API expectations\n- Promise-aware: all AJAX requests are promise-compliant, using `Ember.RSVP.Promise`\n- Value-aware: response values can be directly bound to templates; Ember's binding will auto-update values seamlessly\n- Declarative model relationships: specify child models just as you would any other field; one-to-many relationships are just lists of children\n- Limited concerns: don't be forced into auto-magic 'caching' behaviors; if you want caching, layer that on top of Heisenberg\n\n## Example Usage\n\n```javascript\n\nrequire('ember-heisenberg');\n\n// Model definitions\n\nApp.Company = EH.Object.extend({\n\tname: EH.stringField()\n});\n\nvar Company = App.Company;\n\nApp.Employee = EH.Object.extend({\n\tid: EH.numberField(),\n\tname: EH.stringField(),\n\taliases: EH.stringList(),\n\n\t// embedded objects\n\tcompany: EH.field(Company),\n});\n\nvar Employee = App.Employee;\n\n// Resource Setup\n\nApp.EmployeeResource = EH.Resource.extend();\n\nApp.EmployeeResource.reopenClass({\n\tload: function(id) {\n\t\tvar request = this.method('GET')\n\t\t\t// query/path parameters are templatized\n\t\t\t.url('/employee/{id}', {id: id}))\n\n\t\t\t// specify the expected return object to facilitate deserialization\n\t\t\t.produces(Employee);\n\n\t\t// This returns an object which has getResponsePromise() and getResponseValue() functions\n\t\treturn App.EmployeeResource.executeRequest(request);\n\t},\n\n\tcreate: function(Employee) {\n\t\tvar request = this.method('POST')\n\t\t.url('/Employee')\n\t\t.body(Employee.toJson())\n\t\t.produces(Employee);\n\n\t\treturn App.EmployeeResource.executeRequest(request);\n\t}\n });\n\n\n// Using Resources\n\n// Use AJAX responses as promises...\nvar isBluth = App.EmployeeResource\n\t\t\t\t.load(10)\n\t\t\t\t.getResponsePromise()\n\t\t\t\t.then(doSomethingWithEmployee);\n\nfunction doSomethingWithEmployee(employee) {\n\treturn employee.get('name') === 'Bluth';\n}\n\n// ...or use them as values, which will be asynchronously set\nvar employee = App.EmployeeResource\n\t\t\t\t.load(11)\n\t\t\t\t.getResponseValue();\n\n// Creating a new record and handle a failure of the save\nvar employee = App.Employee.create()\nemployee.set('name', 'Boy George')\n\nvar resultOfSave = App.EmployeeResource\n\t\t\t\t\t\t.create(Employee)\n\t\t\t\t\t\t.getResponsePromise()\n\t\t\t\t\t\t.then(doSomethingPostSaveSuccess)\n\t\t\t\t\t\t.catch(doSomethingPostSaveFail);\n\nfunction doSomethingPostSaveSuccess() {\n\treturn 1;\n}\n\nfunction doSomethingPostSaveFail() {\n\treturn 0;\n}\n```\n\n# Building Ember-Heisenberg\n\n1. Install node: http://nodejs.org/\n- Install dependencies: `npm install`\n- Build and run tests: `grunt`\n- Output will be in `dist/`\n\n# Tests\n\nHeisenberg uses [Karma](http://karma-runner.github.io) as its test runner. Tests are run automatically\nas a part of the build process, but you can invoke the tests manually with `grunt karma:unit`.\n\nYou can also run the tests continuously (they will auto-watch any dependencies) with `grunt karma:dev`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fretailmenot%2Fember-heisenberg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fretailmenot%2Fember-heisenberg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fretailmenot%2Fember-heisenberg/lists"}