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

Inconsistent way of importing classes in examples #1187

Closed
danielpeintner opened this issue Dec 7, 2023 · 2 comments · Fixed by #1192
Closed

Inconsistent way of importing classes in examples #1187

danielpeintner opened this issue Dec 7, 2023 · 2 comments · Fixed by #1192

Comments

@danielpeintner
Copy link
Member

e.g. HTTP

Servient = require("@node-wot/core").Servient;
HttpClientFactory = require("@node-wot/binding-http").HttpClientFactory;

vs. CoAP

const { Servient, Helpers } = require("@node-wot/core");
const { CoapClientFactory } = require("@node-wot/binding-coap");

or also in the same file in root README

node-wot/README.md

Lines 144 to 146 in 7334567

// Required steps to create a servient for creating a thing
const Servient = require('@node-wot/core').Servient;
const HttpServer = require('@node-wot/binding-http').HttpServer;

vs.

node-wot/README.md

Lines 182 to 184 in 7334567

// Required steps to create a servient for a client
const { Servient, Helpers } = require("@node-wot/core");
const { HttpClientFactory } = require('@node-wot/binding-http');

I think we should agree on the "proposed" way!

@danielpeintner danielpeintner changed the title Inconsistent way of importing in examples Inconsistent way of importing classes in examples Dec 7, 2023
@JKRhb
Copy link
Member

JKRhb commented Dec 12, 2023

I think I would prefer the

 const { Servient, Helpers } = require("@node-wot/core"); 
 const { HttpClientFactory } = require('@node-wot/binding-http'); 

approach since it looks a bit cleaner and also avoids some redundancy.

@egekorkan
Copy link
Member

Agreeing with @JKRhb direction. Also, this would promote "better" code since with the other approach one can write const BestServer = require('@node-wot/binding-http').HttpServer;

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

Successfully merging a pull request may close this issue.

3 participants