{"id":20526006,"url":"https://github.com/codeyellowbv/marionette-throttle","last_synced_at":"2025-03-06T01:41:10.463Z","repository":{"id":66356463,"uuid":"53050267","full_name":"CodeYellowBV/marionette-throttle","owner":"CodeYellowBV","description":"Marionette behavior for throttling methods.","archived":false,"fork":false,"pushed_at":"2016-06-23T09:43:10.000Z","size":152,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-01-16T11:26:55.144Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/CodeYellowBV.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-03-03T12:56:30.000Z","updated_at":"2016-08-15T13:11:13.000Z","dependencies_parsed_at":"2023-02-22T06:30:54.569Z","dependency_job_id":null,"html_url":"https://github.com/CodeYellowBV/marionette-throttle","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeYellowBV%2Fmarionette-throttle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeYellowBV%2Fmarionette-throttle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeYellowBV%2Fmarionette-throttle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeYellowBV%2Fmarionette-throttle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CodeYellowBV","download_url":"https://codeload.github.com/CodeYellowBV/marionette-throttle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242133336,"owners_count":20077095,"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-15T23:11:49.115Z","updated_at":"2025-03-06T01:41:10.436Z","avatar_url":"https://github.com/CodeYellowBV.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# marionette-throttle\n\nThrottle methods! This is commonly used to disable multiple clicks on a button.\nEach method which you want to throttle should return a promise. Every time a\nmethod is invoked, an event is dispatched.\n\n```\n$ npm install marionette-throttle --save\n```\n\n## Usage\n\nDefine a view as follows:\n```js\nvar Marionette = require('marionette'),\n    throttleBehavior = require('marionette-throttle');\n\nreturn Marionette.ItemView.extend({\n    behaviors: {\n        throttle: {\n            behaviorClass: throttleBehavior\n            methods: ['save']\n        }\n    },\n    events: {\n        // Method name inside event string.\n        throttle:save:enabled: 'enableSomeCssStuff',\n        throttle:save:disabled: 'disableSomeCssStuff',\n\n        // Method name as an argument.\n        throttle:enabled: function (methodeName) {},\n        throttle:disabled: function (methodeName) {}\n    },\n    // This function will be wrapped because its name is present in\n    // the behavor `methods` config.\n    save: function (e) {\n        e.preventDefault();\n\n        return this.view.model.save();\n    }\n})\n\n```\n\nNormally you will only have 1 button which triggers an action:\n\n```\n    events: {\n        'click @ui.saveButton': 'save'\n    },\n    save: function (e) {\n        // Some save action.\n    }\n```\n\nIf you also want to programmatically call the `save` action (e.g. `this.save()`), then it is recommended to split the save into two functions. This way you can throttle `saveByEvent` and use the `save` function programmatically without being throttled.\n\n```\n    events: {\n        'click @ui.saveButton': 'saveByEvent'\n    },\n    saveByEvent: function () {\n        this.save();\n    },\n    save: function () {\n        // Some save action.\n    }\n```\n\n\n# Changelog\n\n## 0.1.3\n- Add check for method existance. Now it won't bind to method that don't exist.\n\n## 0.1.2\n- Fix bug in passing through arguments.\n\n## 0.1.1\n- Unify enable / disable code.\n\n## 0.1.0\n- Backbone \u0026 marionette aren't included in the dist anymore.\n- Add support for form submit.\n- Call preventDefault by default.\n\n## 0.0.5\n- Typo.\n\n## 0.0.4\n- Typo.\n\n## 0.0.3\n- Add option `className` which defaults to  `throttled`. You can use this for styling.\n- Upgraded build tools.\n\n## 0.0.2\n- Added check to use triggerMethod only if view is not yet destroyed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeyellowbv%2Fmarionette-throttle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodeyellowbv%2Fmarionette-throttle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeyellowbv%2Fmarionette-throttle/lists"}