Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Dart designed to be used for single page applications?

Tags:

dart

I have been trying around Dart for a couple of days and I noticed, it seems to have the same problem with GWT on dealing with multiple view and tracking the navigation history.

GWT addressed that with the MVP (Activities and Places), however it seems to be a bit uncomfortable to write all those classes for a very common function.

Somebody showed me a frameworks for dealing with multiple pages with dart using router, but it looks very much like MVP, in my opinion.

My question is, is dart intended to be used like a flash site, java applet, or any single page sites like Google Maps?

If I am designing an application, should I plan it as a single page and ensure browser back buttons are disabled?

Lastly, on the example page, all examples seem to only have a single page, any links for examples on multiple html pages that pass parameters in between?

Thank you.

like image 323
javapadawan Avatar asked Feb 12 '23 06:02

javapadawan


2 Answers

Dart is definitely for single page applications.
All you have to do when you want to change the view is to remove some HTML and add some others.

With Polymer its easy because you can build a view as component and just remove one component and add another.

Polymer provides <template if="{{...}}"> for that to show as specific view depending on some state in the model, but it also can be done imperatively (through Dart code).

What the router packages helps especially is to connect an URL with a view. It allows to make views bookmarkable and to keep the back/forward browser buttons working for switching back/forth between recently shown views without reloading the page.

You can do this all in your own code without the router package by subscribing to some browser events and modify the browser history in your code but this can become cumbersome.

like image 157
Günter Zöchbauer Avatar answered Apr 01 '23 04:04

Günter Zöchbauer


It is more convenient to use Dart for single page applications. If you use Dart that way, you could manage browser history manually, by using different packages like https://pub.dartlang.org/packages/route or without it, but ut could take a little bit more time and code.

You also could check AngularDart and PolymerDart. Here is a good article about differences and common parts in those frameworks: https://pub.dartlang.org/packages/route

Of course, you could create good old multi-page application when you ask server for different page and so on. And in that case, every page of you app will be like a little app. The same situation, if you would use JavaScript. But this is quite uncommon scenario nowadays.

And also, don't forget, that Dart is not only language for frontend development, but it also a very good tool for server-side development, too. You could share some of pieces of you code between server and client.

like image 31
Andrei Chernykh Avatar answered Apr 01 '23 03:04

Andrei Chernykh