Comments (8)
Whats the status on this? Should we wait until we chat with the libp2p2 team?
from js-libp2p-gossipsub.
I think we should wait until the chat with the libp2p team. I will contact Raul again to see what their availability is on their end.
from js-libp2p-gossipsub.
During the call, there were several ideas about how to go about this. For now, we will be making bindings for gossipsub and potentially in the future, make them for libp2p.
from js-libp2p-gossipsub.
The issue was that as soon as you begin typing a module, you realise that that module likely uses classes or objects from another module (e.g. switch, connection manager, etc.), which ideally would be typed as well.
To avoid galavanting around all of libp2p typing everything at once, you can either use any
, object
, or type the element locally with only the methods and properties you are using from within gossipsub.
EDIT: As you eventually make your way around the codebase, the types you define at the origin sites will be supersets of the local types at call site, so they can easily subsume those without causing breakage.
from js-libp2p-gossipsub.
^^ let me know if you need an example of the above. Feels kinda abstract.
from js-libp2p-gossipsub.
If we type the element using any
or object
, I think that defeats the purpose of using types and we don't get the "built-in" documentation that using TypeScript provides. By locally typing elements, do you mean something like this?
from js-libp2p-gossipsub.
That's an interesting approach that's enabled by typeRoots. That could definitely work -- and in fact we can go over those types at the Polkadot repo and revise them in order to, eventually, add them to the corresponding repos at libp2p.
What I had in mind was something like this. Imagine an index.d.ts
file in this repo's root (names are all made up examples):
declare module 'js-libp2p-switch' {
interface libp2pswitch {
// lazily declare only the methods and fields you use.
methodA(): typeA;
methodB(): typeB;
readonly fieldC: typeC;
}
}
class GossipSub {
static public readonly switch: libp2pswitch;
subscribe(topic: string): Result;
}
But yeah, I agree that placing the ambient declarations for each imported module in a file of its own, and linking it via typeRoots is probably cleaner and better scoped.
On a related note, let's try and converge our types with Polkadot's!
from js-libp2p-gossipsub.
Closing since its stale
from js-libp2p-gossipsub.
Related Issues (20)
- Publish in batch
- Review cached control
- Memory leak due to hash collision HOT 3
- Add CI to test installation as a library
- Add per publish call allowPublishToZeroPeers option
- Not bound GossipPubSub results in "addIP" being undefined
- gsub.on() is not a function HOT 2
- Pubsub stop working after peer restart. HOT 1
- Tag mesh peers on graft, remove tags on prune HOT 4
- js gossipsub not working in browser. HOT 9
- Peers drop connection and don't reconnect HOT 2
- how to validate if ihave/iwant is working? HOT 1
- Leaked outbound and peers HOT 3
- New option for publish api to ignore duplicate
- Implement whatthediff HOT 1
- Add logger option HOT 2
- Delayed IWANT messages from Lodestar to Nimbus HOT 1
- Newly connecting nodes don't interconnect HOT 1
- Missed responded IWANT messages from Nimbus to Lodestar HOT 4
- Missed Iwant messages from Lodestar to Nimbus HOT 2
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 js-libp2p-gossipsub.