xstate.dart icon indicating copy to clipboard operation
xstate.dart copied to clipboard

Feature Request/Suggestion

Open seanaguinaga opened this issue 5 years ago • 2 comments
trafficstars

Unlike TypeScript, Dart can't simply apply an Interface to incoming data, like JSON, and have it "just work." (Which is a huge bummer, and makes functional programming harder)

Because of this and other language design choices, handling async data and requests, especially multiple requests, with xstate in dart, will be more difficult than it already is in TypeScript.

Packages like built_value, and built_collection, come with json serialization built in.

They also have a lot of other features that would be great if inherited by xstate.

I'm asking if there is a way to link xstate with these two other packages, and use code_gen to do so?

If xstate wants to widely be used in Dart, code generation may be necessary, and json serialization should be made as easy as possible.

mobx makes use of code_gen to make development super easy.

There are lots of benefits to using code_gen, built_value, and built_collection in projects, so I thought I'd suggest them.

Let me know if you'd need help of are excepting pull requests.

seanaguinaga avatar Feb 08 '20 21:02 seanaguinaga

Thanks @seanaguinaga, for you suggestion. You are right dart type system is not powerful like typescript. But you can actually make something that works without any code generation but the problem is you lose all the type safety and code completion. My plan is to to create a analyzer_plugin for this that makes suggestions and errors. If it works it is even more powerful than typescript. (Installing a plugin is easy too just one line in analyzer_options.yaml) My problem with code generation are

  • some times generated code is out of sync (2 or 3 seconds but this makes flutter hot reload slower)
  • extra steps for running an app (you need to open two terminals)

I'm still experimenting my method But if this fails I will use code generation (or a combination of both)

That is my plan for this matter if you think code generation may be better feel free to tell me I didn't start writing the plugin yet.

I'm preparing a road map this week I will definitely be glad if someone helps after that.

sahandevs avatar Feb 09 '20 04:02 sahandevs

I'm excited with this project, I'll keep watching it and try help it with what I can.

irvine5k avatar Feb 09 '20 11:02 irvine5k