Giter Club home page Giter Club logo

Comments (4)

acrisci avatar acrisci commented on September 27, 2024

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.

acrisci avatar acrisci commented on September 27, 2024

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.

yannickadam avatar yannickadam commented on September 27, 2024

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.

acrisci avatar acrisci commented on September 27, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.