synchronize icon indicating copy to clipboard operation
synchronize copied to clipboard

using simple await defer with Firebase callback throws error

Open eladkarakuli opened this issue 9 years ago • 4 comments

I'm trying to wrap and sync Firebase query methods as follows

sync.fiber(function() {
            var ref = sync.await(spotsRef.once('value', sync.defer()));
            console.log("ref", ref);
            return ref;
        });

And I get this error:

/home/my-app/node_modules/synchronize/sync.js:111
        fiber.throwInto(err)
              ^
[object Object]

API for Firebase .once method

eladkarakuli avatar Dec 14 '15 09:12 eladkarakuli

.once method like this? https://github.com/firebase/firebase-util/blob/d3a5b7d95/test/e2e/NormalizedCollection.e2e.js#L89

if that, i think you should change to this :)

sync.fiber(function() {
    var defer = sync.defer();
    spotsRef.once('value',
                  function(s) { defer(null, s); }, // success callback
                  defer);                          // failure callback
    var ref = sync.await();
    console.log('ref', ref);
    return ref;
});

d3m3vilurr avatar Dec 15 '15 02:12 d3m3vilurr

Thanks @d3m3vilurr! that worked.

eladkarakuli avatar Dec 17 '15 20:12 eladkarakuli

Close this?

bradvogel avatar Apr 21 '16 18:04 bradvogel

@bradvogel Yea, this issue is not a bug. :) But only can close @alexeypetrushin or @eladkarakuli

d3m3vilurr avatar Apr 22 '16 15:04 d3m3vilurr