We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi,
I have a large app and find it beneficial to sometimes categorise the actions in my Mantra modules:
posts.list.created posts.list.deleted posts.admin.edit // etc...
Possible implementation:
export function injectDeps(context, _actions) { const actions = {}; function bindNested (obj) { var memo = {}; for (var key in obj) { if (obj.hasOwnProperty(key)) { if (typeof obj[key] === 'object') { memo[key] = bindNested(obj[key]); } else { memo[key] = obj[key].bind(null, context); } } } return memo; } for (var key in _actions) { if (_actions.hasOwnProperty(key)) { var actionMap = _actions[key]; var newActionMap = {}; for (var actionName in actionMap) { if (actionMap.hasOwnProperty(actionName)) { var actionOrObj = actionMap[actionName]; if (typeof actionOrObj === 'object') { newActionMap[actionName] = bindNested(actionOrObj); } else { newActionMap[actionName] = actionOrObj.bind(null, context); } } } actions[key] = newActionMap; } } // etc...
Let me know if you'd accept a PR for this :)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi,
I have a large app and find it beneficial to sometimes categorise the actions in my Mantra modules:
Possible implementation:
Let me know if you'd accept a PR for this :)
The text was updated successfully, but these errors were encountered: