How to create previous-dart objects from dart2js output? - dart

Assumed that I code some type of library and convert it to js (per dart2js). How can I access the prototypes to create objects? What is right way to resolve dart-namespaces?

You can expose functions to JavaScript
Expose Dart functions to javascript
Dart SDK 0.8.10.3_r29803 dart:js callbacks
Using Dart with JSON Web Services (it's used for JSONP)
see also js library
I don't think there is a way to expose classes to JavaScript, but I'm not sure about this.

Related

Swagger-ui in Dart

I'm using Dart, and i want to implements swagger-ui, as a web on my proyect.
I have the json/yaml file of my API and that API running on local.
The JS+Css+Html Option of swagger-ui works fine, but, is there a way to generate a web like this in Dart?
I guess I am confused what you want to do.
Dart has it's own documentation generator, dartdoc, that works out of the box for any package. I don't know of any support for swagger or if it offers any particular advantages for Dart users.
An example for args package:
https://www.dartdocs.org/documentation/args/0.13.7/index.html

Mixing encapsulated polymer js components with dart

I have spend some time reading and doing tutorials on dart,polymer, web components. I am wondering the following:
If a (polymer) web component is a encapsulated piece of UI. Why is it not possible (or easier) to use a web components, with perhaps a JS script encapsulated, in a dart project. By just letting the web component do what is suppose to do using for example JS, but hooking it up (with event binding or querySelector) with a dart class which can manipulate it.

How to use DOM modifying libraries along with Angular.dart?

Consider integration of a Dart DOM library like Dart HTML5 Drag and Drop with Angular.dart. Should it be a component? or decorator(directive)? or should one rewrite the controller to use the 3rd party DOM library as a package?
One idea is to use 2 decorators: dragGroup and dropGroup. The value could be a string 'type' in which would link the groups together. So you could have a service/injectable that has a map of 'String type'->(dragGroup,dropGroup). Each decorator would inject that service and install itself's dom element into the respective dragGroup/dropGroup via the Dart HTML5 drag lib.
Whichever way it's done I think it's a cool idea.
It looks like angular ui team has some open requests for it: https://github.com/akserg/angular.dart.ui/issues/54
Hmm, looking further it looks like the idea I described is how it was implemented: https://github.com/akserg/angular.dart.ui/tree/master/lib/dragdrop

How to inject a Dart file in tab?

Dartium does interpret dart files and it opens plenty of fun to develop new toys, and Chrome extensions and apps. But when it comes to do scripts injection in web pages, the executeScript method only takes files supposedly one of the .css and .js formats. Files in other mimetype (typically application/dart) is offbound. Therefore, the question is pretty much naive:
Is there anyway to directly inject a Dart file?
Thanks.
Not a way to directly inject dart-files, but a workaround to inject your dart-application would be to use dart2js and than inject the compiled js-file myDartScript.dart.precompiled.js of your dart-script.
(Use the precompiled-version to avoid errors against the Content Security Policy)
Maybe you also have to inject packages/browser/dart.js and packages/browser/interop.js.
Untested

TypeScript in MVC

Im bulding a website using MVC4. Recently I've read about TypeScript. It looks really nice however I cannot find any use for it in a MVC website. Am I missing something? Do you use it? Where?
TypeScript is a pre-compiler for JavaScript. Hence you can use TypeScript only as a replacement for JavaScript (server-side, e.g. Node.js, or client-side, i.e. in the browser).
As you are probably writing MVC4 code with C#, TypeScript will be of no use for you in relation to MVC4.
Regarding the client-side it's somewhat different.
I guess the main point you need to know is that TypeScript is not (yet) just another language on the server, that you can exchange with C#.
I find it quite useful for building largish apps with lots of logic on the client. The interfaces help avoid some errors. It compiles to javascript so you could use it instead of javascript. If you're just writing a couple of lines I wouldn't bother though.
You can link to the generated javascript files from TS files directly in the script bundles or HTML. If you want to automatically link to many JS files, use require JS. This will save you having to link to many js files.

Resources