{"id":20038527,"url":"https://github.com/yahoo/fluxible-action-utils","last_synced_at":"2025-08-29T16:23:03.272Z","repository":{"id":27786447,"uuid":"31275292","full_name":"yahoo/fluxible-action-utils","owner":"yahoo","description":"Utility methods to aid in writing actions for fluxible based applications.","archived":false,"fork":false,"pushed_at":"2024-04-23T13:48:25.000Z","size":355,"stargazers_count":34,"open_issues_count":5,"forks_count":5,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-08-01T13:55:09.605Z","etag":null,"topics":["flux","fluxible","javascript","ui","web","webpack"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yahoo.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-02-24T18:35:23.000Z","updated_at":"2022-11-12T15:41:39.000Z","dependencies_parsed_at":"2023-02-13T01:45:52.092Z","dependency_job_id":"5d84cf15-688c-44df-a39c-d505dc180b20","html_url":"https://github.com/yahoo/fluxible-action-utils","commit_stats":{"total_commits":162,"total_committers":19,"mean_commits":8.526315789473685,"dds":0.5617283950617284,"last_synced_commit":"112af1f5e319bf6907b3461f20da5c1c670622d0"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/yahoo/fluxible-action-utils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yahoo%2Ffluxible-action-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yahoo%2Ffluxible-action-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yahoo%2Ffluxible-action-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yahoo%2Ffluxible-action-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yahoo","download_url":"https://codeload.github.com/yahoo/fluxible-action-utils/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yahoo%2Ffluxible-action-utils/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272718468,"owners_count":24981490,"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","status":"online","status_checked_at":"2025-08-29T02:00:10.610Z","response_time":87,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["flux","fluxible","javascript","ui","web","webpack"],"created_at":"2024-11-13T10:29:48.196Z","updated_at":"2025-08-29T16:23:03.227Z","avatar_url":"https://github.com/yahoo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fluxible-action-utils\n\n[![npm version](https://badge.fury.io/js/fluxible-action-utils.svg)](http://badge.fury.io/js/fluxible-action-utils)\n![github actions](https://github.com/yahoo/fluxible-action-utils/actions/workflows/test.js.yml/badge.svg)\n[![Join the chat at https://gitter.im/yahoo/fluxible-action-utils](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/yahoo/fluxible-action-utils?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\nUtility methods to aid in writing [actions](http://fluxible.io/api/fluxible-context.html#executeaction-action-payload-callback-) for [fluxible](http://fluxible.io) based applications.\n\n```bash\nnpm install --save fluxible-action-utils\n```\n\n## Modularized Builds/Requires\n\nThe utility library provides modularized methods, and method categories to aid in providing smaller [browserify](http://browserify.org/) and [webpack](http://webpack.github.io/) builds.\n\n```js\nimport actionUtils from 'fluxible-action-utils';\n```\n\nWill require the entire library, including **all** available methods grouped under their respective method categories.\n\nFor example, the following are equivalent (but will result in varying sized [webpack](http://webpack.github.io/) builds)\n\n### Full Library (results in **largest** build)\n\n```js\nconst executeMultiple = require('fluxible-action-utils').async.executeMultiple;\n```\n\n### Category\n\n```js\nconst executeMultiple = require('fluxible-action-utils/async').executeMultiple;\n```\n\n### Method (results in smallest build)\n\n```js\nconst executeMultiple = require('fluxible-action-utils/async/executeMultiple');\n```\n\n:rotating_light: **WARNING** :rotating_light:\n\nMethods inside the `internals` directory/category are not explicitely exported and are considered unstable.\n\nrequire externally at your own risk as breaking changes inside `internals` will not be considered `breaking` for the library.\n\n===\n\n## API\n\n* [`async`](#async)\n    - [`executeMultiple`](#executemultiple-context-actions-done)\n    - [`executeCritical`](#executecritical-context-actions-done)\n* [`mixins`](#mixins)\n    - [`PeriodicActions`](#periodicactions)\n\n===\n\n### async\n\n*available as of v0.2.0*\n\n```js\nimport asyncActionUtils from 'fluxible-action-utils/async';\n```\n\nMethods grouped under the `async` category are concerned with providing methods that aid in managing the asynchronous control flow of [`fluxible`](http://fluxible.io) actions.\n\n[run-auto](https://github.com/feross/run-auto#usage) is used under the hood to do the actual heavy lifting (thanks to [@feross](https://github.com/feross))\n\n#### executeMultiple (context, actions, [done])\n\n*available as of v0.2.0*\n\n```js\nconst executeMultiple = require('fluxible-action-utils/async/executeMultiple');\n```\n\nUtility method used to execute multiple actions in parallel where possible. Each key in `actions` represents a `task` to be executed (and should be unique).\n\n`actions[task]` can be one of the following\n\n1. {FluxAction} an action to be executed, **cannot** be critical **nor** require params\n2. {Object} an action \"object\" with the follwing properties\n    1. `action` {FluxAction} the action to execute\n    1. `[isCritical=false]` {Boolean} whether the action is **critical**\n    2. `[params]` {Any} parameters to pass to the action when executing it\n3. {Array} {String, String, ..., FluxAction|Object} array which defines the tasks/actions that need to be executed before executing the action of type *1.* or *2.* found at the end of the array.\n\nThe `done` {Function} parameter is optional, but if provided, will be called when all tasks complete (either with success or failure).\nSignature `function (err, results)`\n\nFor each task that fails, the error returned will be aggregated under `err[task]`.\n\n**Example**\n\n```js\n// initHome.js\n\nconst executeMultiple = require('fluxible-action-utils/async/executeMultiple');\nconst UserStore = require('app/stores/UserStore');\n\nmodule.exports = function initHome(context, params, done) {\n    executeMultiple(context, {\n        loadUH: require('UH').actions.load,\n        loadUser: {\n            action: require('app/actions/loadUser'),\n            isCritical: true\n        },\n        loadStuffForUser: [\n            'loadUser',\n            {\n                // will be executed after 'loadUser' task completes successfully\n                action: require('../../actions/loadStuffForUser'),\n                params: context.getStore(UserStore).getGUID()\n            }\n        ],\n        populateUserNotifications: [\n            'loadUH',\n            'loadStuffForUser',\n\n            // will be executed after the 'loadUH' and 'loadStuffForUser' tasks complete successfully\n            require('../../actions/populateUserNotifications')\n        ]\n    }, function (err, results) {\n        // there was at least one error, handle them\n        if (err) {\n            if (err.loadUser) {\n                context.dispatch('CATASTROPHE', err.loadUser);\n            }\n\n            if(err.loadStuffForUser) {\n                context.dispatch('RECOVERABLE', err.loadStuffForUser);\n            }\n            done();\n            return;\n        }\n        // Yay! no errors\n        // ...\n        done();\n    });\n};\n```\n\n#### executeCritical (context, actions, [done])\n\n*available as of v0.2.0*\n\n```js\nconst executeCritical = require('fluxible-action-utils/async/executeCritical');\n```\n\n`executeCritical` allows you to execute a group of actions that are **ALL** deemed critical.  This is a simple shorthand for `executeMultiple` when a group of actions are all critical.\n\n### mixins\n*available as of v0.2.0*\n\n```js\nconst mixins = require('fluxible-action-utils/mixins');\n```\n\nMixins grouped under the `mixins` category are concerned with providing React [component mixins](http://facebook.github.io/react/docs/reusable-components.html#mixins) that simplify using [`fluxible`](http://fluxible.io) actions.\n\n#### PeriodicActions\n*available as of v0.2.0*\n\n```js\nconst PeriodicActionsMixin = require('fluxible-action-utils/mixins/PeriodicActions');\n```\n\nUtility mixin used to make running an action repeatedly (polling an API for example) easier to do.\n\nYou can either write code using the methods exposed by the mixin directly, or you can use the `statics` support.\n\n`uuid` must be a unique identifier, attempting to add another action with the same `uuid` as a currently running periodic action will fail to add.\n\n**Statics Example**\n\n```jsx\n// MyReactComponent.jsx\n\nconst PeriodicActionsMixin = require('fluxible-action-utils/mixins/PeriodicActions');\nconst myPollingAction = require('./myPollingAction');\n\n// Let's say you have a child component that implement the controlling logic for the polling action below\nconst ControlComponent = require('./someControlComponent');\n\nmodule.exports = createReactClass({\n    displayName: 'MyReactComponent',\n    mixins: [PeriodicActionsMixin],\n    statics: {\n        periodicActions: [\n            {\n                uuid: 'MY_UNIQUE_POLLING_ACTION_UUID_STATICS',\n                action: myPollingAction,\n                // Optional params\n                params: {\n                    customPayload: 'payload'\n                },\n                // Optional timeout (Defaults to 100 ms)\n                timeout: 1000\n            }\n        ]\n    },\n    render: function () {\n        // You can pass the auto-binded component methods to the child component to achieve\n        // custom timing on the dedicated action(s)\n        return \u003cControlComponent\n                    startPolling={this.startPeriodicActions}\n                    stopPolling={this.stopPeriodicActions}\n               /\u003e;\n    }\n});\n```\n\n**Code Example**\n\n```jsx\n// MyReactComponent.jsx\n\nconst PeriodicActionsMixin = require('fluxible-action-utils/mixins/PeriodicActions');\nconst myPollingAction = require('./myPollingAction');\n\nmodule.exports = createReactClass({\n    displayName: 'MyReactComponent',\n    mixins: [PeriodicActionsMixin],\n    componentDidMount: function () {\n        this.startPeriodicAction(\n            'MY_UNIQUE_POLLING_ACTION_UUID_CODE',\n            myPollingAction,\n            // Optional params\n            {customPayload: 'payload'},\n            // Optional timeout (Defaults to 100 ms)\n            1000\n        );\n    },\n    /* Don't need this, all periodic actions will be stopped automatically on unmount\n    componentWillUnmount: function () {\n        this.stopPeriodicAction('MY_UNIQUE_POLLING_ACTION_UUID_CODE');\n    },\n    */\n    render: function () {\n        return null;\n    }\n});\n```\n\n## FAQ\n\n* [what is a **critical** action?](https://github.com/yahoo/fluxible-action-utils/issues/18)\n\n## Thanks\n\n* [@mridgway](https://github.com/mridgway)\n* [@akshayp](https://github.com/akshayp)\n* [@redonkulus](https://github.com/redonkulus)\n* [@zeikjt](https://github.com/zeikjt)\n\n## License\n\nThis software is free to use under the Yahoo Inc. BSD license. See the [LICENSE file](https://github.com/yahoo/fluxible-action-utils/blob/master/LICENSE.md) for license text and copyright information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyahoo%2Ffluxible-action-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyahoo%2Ffluxible-action-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyahoo%2Ffluxible-action-utils/lists"}