Web storage

348 views
Skip to first unread message

Leonti Bielski

unread,
Jun 1, 2016, 9:51:14 AM6/1/16
to Elm Discuss
Hi!

I would like to use a web storage in my app but it doesn't seem to be a part of a native library.
Should I use ports for this?

Official TodoMVC app seems to be using ports:
https://github.com/evancz/elm-todomvc/blob/master/index.html

I've found this https://github.com/rgrempel/elm-web-api which does exactly what I need (https://github.com/rgrempel/elm-web-api/blob/master/src/WebAPI/Storage.elm specifically) but it's deprecated.

Do I really have to resort to using ports or it's available somewhere in native Elm?

Cheers,
Leonti

Frederick Yankowski

unread,
Jun 1, 2016, 10:27:29 AM6/1/16
to Elm Discuss
I wrote an effect manager for localstorage, available at https://github.com/fredcy/localstorage.

It's not available as a package as it is blocked, waiting review. https://github.com/elm-lang/package.elm-lang.org/issues/178

Since it includes native JS code, installation is a bit awkward. There are some notes in the README.

Leonti Bielski

unread,
Jun 1, 2016, 6:14:30 PM6/1/16
to Elm Discuss

Hi Frederick! This is awesome, thanks!
Is there any documentation on how to write native modules?


--
You received this message because you are subscribed to a topic in the Google Groups "Elm Discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elm-discuss/oQz5_HvsdcQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elm-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Frederick Yankowski

unread,
Jun 1, 2016, 6:45:48 PM6/1/16
to Elm Discuss
I have not seen any such documentation. One has to work from examples. And the Elm leaders (broadly speaking) actively discourage us from writing native code and effect managers.

Evan

unread,
Jun 1, 2016, 7:34:58 PM6/1/16
to Elm Discuss
Use ports!

Support for "web platform" things will expand as quickly is as manageable with all the other things that need to happen.

Leonti Bielski

unread,
Jun 2, 2016, 4:50:42 AM6/2/16
to Elm Discuss
I completely agree that we shouldn't use Native modules for things that can be written in pure Elm.
If I want runtime errors I will use Javascript, thanks :D

If my understanding is correct browser apis are not possible to write in pure Elm, for example http or web storage for that matter.
I think once those things are covered we won't need to use JS anymore.

But until then if you restrict usage of Native modules to browser apis and make it official we could create "web platform" faster with more contributors.
Any libraries that use native code as wrappers for existing Javascript libraries should be rejected.



--
Reply all
Reply to author
Forward
0 new messages