🌐 AI搜索 & 代理 主页
Skip to content

Actual alternative to .pipe()? #4134

@JakenVeina

Description

@JakenVeina

Obviously, .then() is listed as the official replacement for .pipe(), however as described in #3325, .then() forces execution of the callback onto a new context, even in the case of a promise/deferred that is already resolved, unlike .pipe().

In the following case, .then() is not a suitable replacement for .pipe(), for the above reason.

var promise = someAsyncOperation()
    .then(function(results)) {
        return processResults(results);
    });

if (promise.state() !== "resolved") {
    $overlay.fadeIn(500);

    promise
        .done(function() {
            $overlay.fadeOut(500);
        });
}

return promise;

If someAsyncOperation() utilizes .then() to filter results anywhere in the call chain, the $overlay animations will play unintentionally.

As far as I can tell, there's no alternative in the current library to combine the "immediate callback" behavior of .done() with the filtering behavior of .then(), except for the deprecated method .pipe(). Am I missing something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions