mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 04:29:21 +03:00
Replaced tricky delegateRunOnDestroy() with koArrayWithDestroy()
koArrayWithDestroy creates ko.observableArray and calls the desired onDestroy() on entry delete.
This commit is contained in:
parent
f4bc796fb1
commit
e324e2f6b6
13 changed files with 32 additions and 55 deletions
13
dev/External/ko.js
vendored
13
dev/External/ko.js
vendored
|
|
@ -21,7 +21,18 @@ export const
|
|||
addSubscribablesTo = (target, subscribables) =>
|
||||
forEachObjectEntry(subscribables, (key, fn) => target[key].subscribe(fn)),
|
||||
|
||||
dispose = disposable => disposable && isFunction(disposable.dispose) && disposable.dispose();
|
||||
dispose = disposable => disposable && isFunction(disposable.dispose) && disposable.dispose(),
|
||||
|
||||
// With this we don't need delegateRunOnDestroy
|
||||
koArrayWithDestroy = data => {
|
||||
data = ko.observableArray(data);
|
||||
data.subscribe(changes =>
|
||||
changes.forEach(item =>
|
||||
'deleted' === item.status && null == item.moved && item.value.onDestroy && item.value.onDestroy()
|
||||
)
|
||||
, data, 'arrayChange');
|
||||
return data;
|
||||
};
|
||||
|
||||
ko.bindingHandlers.tooltipErrorTip = {
|
||||
init: (element, fValueAccessor) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue