LearnNewsExamplesServices
Frontmatter
id2789
titlecore.Observable:fire() => add a check for string based event handlers
stateClosed
labels
enhancement
assigneestobiu
createdAtJan 2, 2022, 3:44 PM
updatedAtJan 2, 2022, 3:56 PM
githubUrlhttps://github.com/neomjs/neo/issues/2789
authortobiu
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJan 2, 2022, 3:56 PM

core.Observable:fire() => add a check for string based event handlers

Closed v8.1.0 enhancement
tobiu
tobiu commented on Jan 2, 2022, 3:44 PM

by default, view controllers will map those into their scope, if available.

however, in case we want to override event handlers (e.g. when defining a plugin), it can be handy to go for string based events which will get scoped to their fn once the first event fires.

example (list.Base):

afterSetStore(value, oldValue) {
    let me = this;

    value?.on({
        filter      : me.onStoreFilter,
        load        : me.onStoreLoad,
        recordChange: me.onStoreRecordChange,
        scope       : me
    });

    value?.getCount() > 0 && me.onStoreLoad();
}

could become:

afterSetStore(value, oldValue) {
    let me = this;

    value?.on({
        filter      : 'onStoreFilter',
        load        : 'onStoreLoad',
        recordChange: 'onStoreRecordChange',
        scope       : me
    });

    value?.getCount() > 0 && me.onStoreLoad();
}

in which case list.plugin.Animate can override the store event-handlers.

tobiu added the enhancement label on Jan 2, 2022, 3:44 PM
tobiu assigned to @tobiu on Jan 2, 2022, 3:44 PM
tobiu referenced in commit 1b01847 - "core.Observable:fire() => add a check for string based event handlers #2789" on Jan 2, 2022, 3:45 PM
tobiu referenced in commit 65211a2 - "#2789 adjusted list.Base and list.plugin.Animate to test string based event handlers" on Jan 2, 2022, 3:48 PM
tobiu closed this issue on Jan 2, 2022, 3:56 PM