The Dart web platform supports calling JavaScript using the js package, also known as package:js. For help using the js package, see the following: Documentation for the js package: pub.
Dart is a client-oriented programming language created by Google in 2011 and is designed to make fast applications for any platform. Google started it as an internal programming language for developing web, server, and mobile apps. Dart compiles source code the same way like C, JavaScript, Java, and C# do.
I would like to write a javascript library (framework), but need OOP and mixins.
Was giving a go to typescript, but it doesn't support mixins (the handbook says it does, but the compiler/specifications has nothing that is mixin related).
In typescript, the following code:
class Greeter {
greeting: string;
constructor(message: string) {
this.greeting = message;
}
greet() {
return "Hello, " + this.greeting;
}
}
Compiles to:
var Greeter = (function () {
function Greeter(message) {
this.greeting = message;
}
Greeter.prototype.greet = function () {
return "Hello, " + this.greeting;
};
return Greeter;
})();
Then clients can simply call:
var greeter = new Greeter("world");
Can dart do something similar? Can someone show how?
The main goal is that the produced javascript code is readable, preferably with all the dart extras residing in a different script.
I've seen this question and this answer, but neither seem to yield a readable JS file, like in the typescript example above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With