Comments (2)
gun is not promise/async based..
the best way to handle async stuff is to wrap with your own promise logic like this example
var Gun = require("gun")
var gun = Gun();
async function getData() {
return new Promise((res) => {
var chain = gun.get("test").get("hello").on((data) => {
if (data) {
chain.off();
res(data)
}
})
})
}
async function putData(data) {
gun.get("test").get("hello").put(data)
return await getData()
}
async function run() {
var data = await putData("world");
console.log(data)
}
run();
from gun.
gun is not promise/async based..
the best way to handle async stuff is to wrap with your own promise logic like this example
I believe this is very close to what is implemented already in gun.then and what I think is used to "trick" js into woking with await's - because for the most part awaiting works fine. see docs
I realized however, that the issue is not so much a problem with await but that in general the .on call is not fired!
This does not work:
gun.get("foo").get("name").on(name => console.log("name is: ", name)); // never runs
const thing = gun.get("thing").get("element").put("alice");
gun.get("foo").get("name").put(thing);
from gun.
Related Issues (20)
- Why is the source code so bad? HOT 2
- Can not access docs HOT 2
- load() issue HOT 2
- Gun integration with express not working HOT 3
- Once dosen't trigger most of the time, when messages are authenticated to an user. HOT 1
- Gun not working with next.js 14.0.4 HOT 10
- Gun reports all documents always not only changed ones
- [BUG] Error when importing 'gun/lib/time.js' in nodejs HOT 1
- Use trystero for webrtc (with bittorrent dht signalling) HOT 8
- [BUG] mapping values in gun.user does not work properly HOT 10
- Setup without build tools HOT 1
- Proposal: GUN URIs to universally reference data HOT 2
- Question: How to split and distribute work? HOT 1
- Question: webseed functionality? HOT 1
- Have AI gen some contributor docs, docstrings, comments HOT 13
- node-webcrypto-oss deprecated HOT 3
- [BUG] gun server / nodejs / ERROR: Radisk needs `store.put` interface with `(file, data, cb)`!
- Problems with Node.js Scripts for Push/Pull Operations HOT 1
- not working even in same computer between to tab HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gun.