mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
Client: async resources, make store reusable, move plugins and add getTaskFor getter (#8575)
Add library to manage async resource Make Store reusable for easier testing Move plugin to libs Add getTaskFor getter with tests
This commit is contained in:
32
website/client/libs/store/helpers/internals.js
Normal file
32
website/client/libs/store/helpers/internals.js
Normal file
@@ -0,0 +1,32 @@
|
||||
/* Flatten multiple objects into a single, namespaced object.
|
||||
|
||||
Example:
|
||||
|
||||
getters
|
||||
user
|
||||
gems
|
||||
tasks
|
||||
...
|
||||
tasks
|
||||
todos
|
||||
dailys
|
||||
...
|
||||
|
||||
Result:
|
||||
getters
|
||||
user:gems
|
||||
user:tasks
|
||||
tasks:todos
|
||||
tasks:dailys
|
||||
*/
|
||||
export function flattenAndNamespace (namespaces) {
|
||||
let result = {};
|
||||
|
||||
Object.keys(namespaces).forEach(namespace => {
|
||||
Object.keys(namespaces[namespace]).forEach(itemName => {
|
||||
result[`${namespace}:${itemName}`] = namespaces[namespace][itemName];
|
||||
});
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user