Comments (4)
The thing is that the decorators are just so damn beautiful I couldn't help myself. And they'll be usable one day and it will no longer be a problem.
I have an example babel setup here:
https://github.com/dbusjs/node-dbus-next/tree/master/examples/service
And it works in the widely used mpris-service package:
https://github.com/dbusjs/mpris-service
But to actually answer your question, there is no currently supported way to do this. But we could add something for it for compatibility and it wouldn't be hard.
// after the service class is declared...
MyService.configureMembers({
properties: [
// configure properties
],
methods: [
// configure methods
],
signals: [
// configure signals
]
});
It's just a matter of implementing that.
from node-dbus-next.
I've added an alternative interface. For a usage example, see this test:
https://github.com/dbusjs/node-dbus-next/blob/master/test/integration/configured-service.test.js
class ConfiguredTestInterface extends Interface {
SomeProperty = 'foo';
Echo(what) {
return what;
}
HelloWorld() {
return [ 'hello', 'world' ]
}
EmitSignals() {
this.HelloWorld();
}
}
ConfiguredTestInterface.configureMembers({
properties: {
SomeProperty: {
signature: 's'
}
},
methods: {
Echo: {
inSignature: 'v',
outSignature: 'v'
},
EmitSignals: {}
},
signals: {
HelloWorld: {
signature: 'ss'
}
}
});
Let me know if this is usable for you and I'll document it and put it in the next release.
from node-dbus-next.
Hi @acrisci,
Thanks for this library! I agree with you that decorators looks much better. However, would you please consider using the legacy support from babel? This would make your implementation compatible with TypeScript. The changes to be done on your side are trivial, and would only require babel users to change the plugin they use while compiling.
Moreover, from https://github.com/tc39/proposal-decorators, they clearly advise against using the new babel syntax:
How should I use decorators in transpilers today?
Unfortunately, we're in the classic trap of, "The old thing is deprecated, and the new thing is not ready yet!" For now, best to keep using the old thing.
The decorators champion group would recommend continuing to use Babel "legacy" decorators or TypeScript "experimental" decorators. If you're using decorators today, you're probably already using one of these versions. Note that these decorators depend on "[[Set]] semantics" for field declarations (in Babel, loose mode). We recommend that these tools maintain support for [[Set]] semantics alongside legacy decorators, until it's possible to transition to the decorators of this proposal.
Babel 7 supports the decorators proposal presented to TC39 in the November 2018 TC39 meeting. It's fine to use these for experimental purposes, but they face significant performance issues, are not yet widely adopted; we don't plan to continue pushing for this proposal in TC39. As such, we recommend against using this version for serious work. In follow-on proposals to add more built-in decorators, we hope to be able to recover the extra functionality that the November 2018 decorators proposal supported.
from node-dbus-next.
@yannickadam I think we can just support both. We can just put the legacy decorators in another file and you can import from there instead.
from node-dbus-next.
Related Issues (20)
- support TypeScript decorators HOT 2
- Logging errors from event handlers HOT 2
- ProxyObject or Interface went away event missing
- automatic (de)serialization to Variant dicts
- Unable to serialize a{sa{sv}} HOT 2
- no response frpm method
- New release
- Notification example?
- Multiple D-Bus errors occur (application runs fine, however) HOT 1
- Bug: Nodes not added to ProxyObject with root path ("/")
- Vulnerability in `[email protected]` dependency HOT 2
- DBUS_COOKIE_SHA1 auth does not work at all
- Project seems dead HOT 1
- nodejs now support abstract unix socket
- systemd service HOT 2
- Issue when trying to fetch mpris tracks metadata HOT 1
- Initial signals lost when no previous method call have been made
- Can't bundle it because of `usocket` library HOT 2
- Subscribe to `NameOwnerChanged` by default HOT 3
- Consider using ECMAScript modules? HOT 6
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 node-dbus-next.