{"id":32248527,"url":"https://github.com/alvarobrito/provider-behavior","last_synced_at":"2026-02-18T21:31:23.078Z","repository":{"id":58236129,"uuid":"81006432","full_name":"alvarobrito/provider-behavior","owner":"alvarobrito","description":"Data provider to manage custom data for polymer components","archived":false,"fork":false,"pushed_at":"2017-02-06T09:30:00.000Z","size":19,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-22T16:29:33.369Z","etag":null,"topics":["behavior","polymer","provider","web-components"],"latest_commit_sha":null,"homepage":"","language":"HTML","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/alvarobrito.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-02-05T16:46:49.000Z","updated_at":"2017-06-01T13:03:11.000Z","dependencies_parsed_at":"2022-08-31T09:23:03.069Z","dependency_job_id":null,"html_url":"https://github.com/alvarobrito/provider-behavior","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/alvarobrito/provider-behavior","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alvarobrito%2Fprovider-behavior","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alvarobrito%2Fprovider-behavior/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alvarobrito%2Fprovider-behavior/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alvarobrito%2Fprovider-behavior/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alvarobrito","download_url":"https://codeload.github.com/alvarobrito/provider-behavior/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alvarobrito%2Fprovider-behavior/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29596206,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T20:59:56.587Z","status":"ssl_error","status_checked_at":"2026-02-18T20:58:41.434Z","response_time":162,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["behavior","polymer","provider","web-components"],"created_at":"2025-10-22T17:44:33.513Z","updated_at":"2026-02-18T21:31:23.047Z","avatar_url":"https://github.com/alvarobrito.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# provider-behavior\r\n\r\nBehavior to provide data for components. You can use this Behavior for polymer elements which manage data from API, automatically your data is stored in a closure for state control of your application. Based on [redux](https://github.com/reactjs/redux), but only using the mono-state pattern (Singleton with sugar!).\r\n\r\n## Behavior API\r\n\r\n| method            | Params              | Description  |\r\n| ------------------|:-------------------:| -------------|\r\n| get()             |                     | Gets data from iron-ajax. You can add `auto` property in provider-element to get data and render it automatically                                         |\r\n| set(data,reflect)| ArrayObject, Boolean|   Updates store with the new data, reflect true to apply updating for all same providers.   |\r\n| clearStore()      |                     |    Clears store, only removes data associated to its tagName (eg. all `'PROVIDER-ELEMENT'`) |\r\n\r\n## How to use\r\n\r\n### Data binding from a declarative provider\r\n\r\n```html\r\n\u003cprovider-element auto data=\"{{dataFromProvider}}\"\u003e\u003c/provider-element\u003e\r\n\u003col\u003e\r\n  \u003ctemplate is=\"dom-repeat\" items=\"[[dataFromProvider]]\"\u003e\r\n    \u003cli\u003e[[item.value]]\u003c/li\u003e\r\n  \u003c/template\u003e\r\n\u003c/ol\u003e\r\n```\r\n\u003e provider-element is using the provider-behavior, it automatically gets data from the ```iron-ajax``` element and sets result in its data property.\r\n\r\n### Using a provider method from an external element and reflecting the updated data\r\n\r\n```html\r\n\u003cdom-module id=\"provider-element\"\u003e\r\n  \u003ctemplate\u003e\r\n    \u003ciron-ajax\r\n      id=\"api\"\r\n      url=\"assets/data.json\"\r\n      handle-as=\"json\"\u003e\r\n    \u003c/iron-ajax\u003e\r\n  \u003c/template\u003e\r\n\r\n  \u003cscript\u003e\r\n    Polymer({\r\n      is: \"provider-element\",\r\n\r\n      behaviors: [Polymer.ProviderBehavior],\r\n\r\n      add: function (newItem, reflect) {\r\n        this.set(this.data.concat([newItem]), reflect || false);\r\n      }\r\n    });\r\n  \u003c/script\u003e\r\n\u003c/dom-module\u003e\r\n```\r\n\r\n\u003e You can set data and update all providers which are using the same data in the store. If you want to get that, only pass a second param to `true` as value.\r\n\r\n```html\r\n\u003cdom-module id=\"smart-component\"\u003e\r\n  \u003ctemplate\u003e\r\n    \u003cprovider-element id=\"provider\" auto data=\"{{dataFromProvider}}\"\u003e\u003c/provider-element\u003e\r\n    \u003cdumb-component collection=\"[[dataFromProvider]]\" on-add=\"addElement\" on-add-reflect=\"addAndReflect\"\u003e\u003c/dumb-component\u003e\r\n  \u003c/template\u003e\r\n\r\n  \u003cscript\u003e\r\n    Polymer({\r\n      is: \"smart-component\",\r\n\r\n      addElement: function (e) {\r\n        this.$.provider.add(e.detail);\r\n      },\r\n\r\n      addAndReflect: function (e) {\r\n        this.$.provider.add(e.detail, true);\r\n      }\r\n    });\r\n  \u003c/script\u003e\r\n\u003c/dom-module\u003e\r\n```\r\n\u003e provider-element contains an add method to add new data in the store and reflects this change to all providers which are using this data.\r\n\r\n```html\r\n\u003cdom-module id=\"dumb-component\"\u003e\r\n  \u003ctemplate\u003e\r\n    \u003col\u003e\r\n      \u003ctemplate is=\"dom-repeat\" items=\"[[collection]]\"\u003e\r\n        \u003cli\u003e[[item.value]]\u003c/li\u003e\r\n      \u003c/template\u003e\r\n    \u003c/ol\u003e\r\n    \u003cbutton type=\"button\" name=\"button\" on-click=\"add\"\u003eAdd\u003c/button\u003e\r\n    \u003cbutton type=\"button\" name=\"button\" on-click=\"addAndReflect\"\u003eAdd and reflect\u003c/button\u003e\r\n  \u003c/template\u003e\r\n\r\n  \u003cscript\u003e\r\n    Polymer({\r\n      is: \"dumb-component\",\r\n\r\n      properties: {\r\n        collection: {\r\n          type: Array\r\n        }\r\n      },\r\n\r\n      add: function() {\r\n        this.fire('add', {\r\n          id: Math.random(),\r\n          value: 'New item collection'\r\n        });\r\n      },\r\n\r\n      addAndReflect: function() {\r\n        this.fire('add-reflect', {\r\n          id: Math.random(),\r\n          value: 'New item collection'\r\n        });\r\n      }\r\n    });\r\n  \u003c/script\u003e\r\n\u003c/dom-module\u003e\r\n```\r\n\u003e dumb-component only fires events which are managed by the smart-component\r\n\r\n## Try the provider-behavior demo\r\n\r\nFirst, make sure you have the [Polymer CLI](https://www.npmjs.com/package/polymer-cli) installed. Then run `polymer serve -o ` to serve your application locally.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falvarobrito%2Fprovider-behavior","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falvarobrito%2Fprovider-behavior","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falvarobrito%2Fprovider-behavior/lists"}