Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Varying behavior for then() when not including then library #831

Open
labs-dlugo opened this issue Oct 23, 2019 · 1 comment
Open

Varying behavior for then() when not including then library #831

labs-dlugo opened this issue Oct 23, 2019 · 1 comment

Comments

@labs-dlugo
Copy link

labs-dlugo commented Oct 23, 2019

await gun.get('foo').put() varies its behavior for different users.

For me it returns the data, which matches what the docs say: https://gun.eco/docs/API#-a-name-then-a-gun-then-cb-

await most likely already calls then() on whatever follows it, which is what probably changes the value assigned to a variable from a gun node to data.

Which means that x = await gun.get('foo').put(); /* do something with x */ is equivalent to gun.get('foo').put().then(x => { /* do something with x */})

Screen Shot 2019-10-23 at 13 25 19

This is all not including lib/then, which begs the question why does gun have then() included by default then?

When I include lib/then the behavior is similar except var x = await gun.get('foo').put() never resolves, i have to append then() for it all to work.

For other users (such as @Dletta ), the promise resolves to a GUN Node :

Screen Shot 2019-10-23 at 13 29 27

yarn.lock:

gun@^0.2019.930:
  version "0.2019.930"
  resolved "https://registry.yarnpkg.com/gun/-/gun-0.2019.930.tgz#9251c064d4408958626af3707f7ce0623e0c19b0"
  integrity sha512-JZunmIcZqwq9MgrMHBRVAB7HbgNWUnwnHSJZPq0QCCbJwJ4rRctBcBWZF3BgS3AGpOUM9S+ecSQDacQHYJkujg==
  dependencies:
    ws "~>7.1.0"
  optionalDependencies:
    "@peculiar/webcrypto" "^1.0.19"
    emailjs "^2.2.0"
    text-encoding "^0.7.0"
@amark
Copy link
Owner

amark commented Nov 13, 2019

@danlugo92 maybe we should move this to the documentation (anybody can edit it at https://github.com/amark/gun/wiki/API ) until made consistent / officially supported / rigorously tested?

I'd like this to work, tho need somebody to help write tests for EVERY COMBINATION of uses (there are a lot of combos, even with just a tiny API surface), and ideally somebody who is willing to volunteer time to sit down/screenshare with me as I/we actually add/fix better support (which is very tedious and boring), then it has a much higher chance of actually happening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants