{"id":15016000,"url":"https://github.com/thoov/ember-invoke","last_synced_at":"2025-04-12T10:09:04.919Z","repository":{"id":57223912,"uuid":"106664272","full_name":"thoov/ember-invoke","owner":"thoov","description":"EmberJS helper to invoke methods on a given context such as components or controllers.","archived":false,"fork":false,"pushed_at":"2017-11-30T04:04:48.000Z","size":64,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T10:08:53.447Z","etag":null,"topics":["ember-addon","emberjs","function","handlebars","invoke","method"],"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/thoov.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":"2017-10-12T08:15:05.000Z","updated_at":"2018-06-06T15:24:44.000Z","dependencies_parsed_at":"2022-09-04T07:40:45.055Z","dependency_job_id":null,"html_url":"https://github.com/thoov/ember-invoke","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/thoov%2Fember-invoke","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoov%2Fember-invoke/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoov%2Fember-invoke/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoov%2Fember-invoke/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thoov","download_url":"https://codeload.github.com/thoov/ember-invoke/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248550634,"owners_count":21122933,"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":["ember-addon","emberjs","function","handlebars","invoke","method"],"created_at":"2024-09-24T19:48:16.069Z","updated_at":"2025-04-12T10:09:04.898Z","avatar_url":"https://github.com/thoov.png","language":"JavaScript","readme":"# Ember Invoke\n\nEmberJS helper to invoke methods on a given context such as components or controllers.\n\n## Installation\n\n`ember install ember-invoke`\n\n## Usage\n```hbs\n{{invoke this 'methodName' 'any' 'number' 'of' 'args'}}\n\n{{!-- OR --}}\n\n{{some-component prop=(invoke this 'methodName' 'any' 'number' 'of' 'args')}}\n```\n\n## Why?\n\n```js\n// component/restaurant.js\nimport Component from '@ember/component';\n\nexport default Component.extend({\n  people: [{\n    first: 'Bob',\n    last: 'Smith',\n    age: 43\n  }, {\n    first: 'Jen',\n    last: 'Doe',\n    age: 19\n  }, {\n    first: 'Bill',\n    last: 'Foobar'\n    age: 74\n  }],\n\n  canDrink(age) {\n    return age \u003e= 21;\n  }\n})\n```\n\n```hbs\n{{!-- templates/component/restaurant.hbs --}}\n{{#each people as |person|}}\n\n  \u003ch5\u003e{{person.first}} {{person.last}}\u003c/h5\u003e\n\n  {{!--\n    The only way you could make this work would be to create a\n    `can-drink` helper that you would call like so:\n\n    (can-drink person.age)\n    \n    However, that logic might not make sense outside of the scope of\n    this component. Also, many times the logic is simple (like in this\n    example) and creating a whole separate helper file is over kill.\n    \n    Also note that a computed property wouldn't work as we are within an \n    iteration and cannot create a cp that is bound to an individual item. \n    Instead we would have to create a wrapper cp that adds on these extra\n    properties which may or may not be what you want.\n\n    This is where the invoke helper comes in. Now you can simply `invoke`\n    any method on a given context and it will be called with the arguments\n    that are passed in.\n  --}}\n\n  {{#if (invoke this 'canDrink' person.age)}}\n    \u003cp\u003eis of legal drinking age\u003c/p\u003e\n  {{else}}\n    \u003cp\u003eis \u003cb\u003eNOT\u003c/b\u003e of legal drinking age\u003c/p\u003e\n  {{/if}}\n{{/each}}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthoov%2Fember-invoke","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthoov%2Fember-invoke","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthoov%2Fember-invoke/lists"}