Question: native == javascript?

Asked By
keithalexander
Asked At
2017-11-07 12:50:02

Found 15 possible answers.

User Answered At Possible Answer
purohit 2017-11-07 12:58:10 Yes
ssbb 2017-11-07 13:01:19 yes, but different than ports https://github.com/gdotdesign/elm-github-install https://github.com/panosoft/elm-grove if you really want it - you can use something like Groove or elm-github-install
purohit 2017-11-07 13:02:08 https://groups.google.com/forum/#!topic/elm-dev/1JW6wknkDIo might be of interest
ilias 2017-11-07 13:02:52 Using localstorage (or sessionstorage) through ports is very easy and definitely the recommended path
ssbb 2017-11-07 13:03:14 yeah, but hard to keep in sync @ilias common use for localstorage is a caching. so for example you hashing request body to something like md5 and fetching/saving to LS. so you have reusable function like fetch : Request -> Cmd msg . how you will deal with Ports?
ilias 2017-11-07 13:07:00 load the cache through flags, write out to the cache as you go
ssbb 2017-11-07 13:07:50 for me it don't looks easier than just Task :smile: also in multi-page SPA it will force you to think a lot about what to cleanup/not
ilias 2017-11-07 13:09:14 Different doesn't mean harder, and you get to keep all the safety guarantees that the published Elm packages give you. I'm merely pointing out that the _recommended_ approach is ports, and people tend to think "that'll be complicated", which isn't always true
ssbb 2017-11-07 13:10:44 as an example with flags - it's done only on global initialization. so if you have per-page initialization (like fetch data when page shown) - you will need to think which data should be cleaned and which not (fetched)
ilias 2017-11-07 13:11:25 Backdoors that rely on implementation details and couple packages to those implementation details aren't a good default. The more projects rely on tools like elm-github-install, the harder it becomes to change those implementation details without breaking a lot of applications.
ssbb 2017-11-07 13:12:23 so you visited post list for example. then clicking on single post. there is no cache via flags. you fetching it and saving to cache. if you will go back to post list and will open this post again - how you will get a cache? I know you can just not cleanup it. but in real apps there is things like TTL
ilias 2017-11-07 13:14:43 Put the cache in your model, possibly as a Dict String Value . Use ports to keep that in sync with the localstorage backing. If you're dealing with such large datasets that keeping it in memory is not an option, then you'll need some more logic. If you need TTL, you'll need some more logic. I'm really not looking to discuss this, my main point is and has always been "don't default to packages that require native if you aren't 100% absolutely SURE you need them"
ssbb 2017-11-07 13:15:25 I don't tell it's a good or bad to use Native. But it absolutely has the right to life. Just idea that someone can publish packages with Native and someone not - is wrong in my mind just ask user to copy-paste chunk of code from readme and add it to their ports? @ilias I am working on https://text-mask.github.io/text-mask/ migration to Elm now (almost complete, writing addons). it will require Native or ports to adjust caret position (caret resets when you set value ). what is the best way for me?
ilias 2017-11-07 13:19:57 This isn't a constructive discussion, and definitely not #beginners material. So I'm ejecting myself from the discussion.
ssbb 2017-11-07 13:21:12 sorry, it's not about previous discussion - just really want to know how I can do it in a good way

Related Questions