mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-31 04:59:21 +03:00
Move addObservablesTo, addComputablesTo & addSubscribablesTo to Common/Utils
This commit is contained in:
parent
eda0ee695d
commit
4b6f6b1bfc
18 changed files with 55 additions and 46 deletions
|
|
@ -136,3 +136,16 @@ export function changeTheme(value, themeTrigger = ()=>{}) {
|
|||
.then(clearTimer, clearTimer);
|
||||
}
|
||||
}
|
||||
|
||||
export function addObservablesTo(target, observables) {
|
||||
Object.entries(observables).forEach(([key, value]) =>
|
||||
target[key] = /*Array.isArray(value) ? ko.observableArray(value) :*/ ko.observable(value) );
|
||||
}
|
||||
|
||||
export function addComputablesTo(target, computables) {
|
||||
Object.entries(computables).forEach(([key, fn]) => target[key] = ko.computed(fn));
|
||||
}
|
||||
|
||||
export function addSubscribablesTo(target, subscribables) {
|
||||
Object.entries(subscribables).forEach(([key, fn]) => target[key].subscribe(fn));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue