Effect manager for Device Orientation API

537 views
Skip to first unread message

Igor Drozdov

unread,
Jun 20, 2018, 12:53:34 AM6/20/18
to elm-dev
Hi,

I have an intention of creating a language API for Device Orientation API
Actually, I've already created such a library https://github.com/igor-drozdov/elm-device-orientation (and plan on extending it with device-motion handlers in the future)
I wanted to publish it as an Elm package, but according to the error message, I need to go through a review process
The first link in the message was to the Google groups to discuss, whether the whole idea is reasonable
If we'd better publish the library under elm-lang namespace (just like geolocation and page-visibility libraries), I can try and implement it this way

Anyway, looking forward to hearing from you

Cheers,
Igor

Brian Hicks

unread,
Jun 20, 2018, 4:32:19 PM6/20/18
to elm-dev
Hi Igor!

A big part of being able to publish code like this is justifying why it needs to be done this specific way. What's motivating this change? Can you briefly summarize here, please? It'd be especially helpful if you could talk about:

1. the problem that you're trying to solve
2. the solutions you've tried that don't require Native code or effects managers
3. why those solutions didn't work

I also have a specific concern: this appears to be a pretty direct wrapping of a browser API which MDN lists as experimental and which the W3C says is no longer under active maintenance. That rings some warning bells for me! Knowing what problem you're trying to solve may help us come to a better solution which solves the problem without tightly binding the library to an unstable target.

Thanks,
Brian

Igor Drozdov

unread,
Jun 21, 2018, 1:35:00 PM6/21/18
to elm-dev
Hi Brian!

Thanks for your response

> 1. the problem that you're trying to solve
I have an idea of integrating Device Orientation with my project. For example, I need to know the position, orientation of the mobile device of a user and react somehow on these actions. Even though the API is still in experimental stage, it's supported in most browsers, so why not try it

> 2. the solutions you've tried that don't require Native code or effects managers
As far as I know, there are two ways of speaking to JS in Elm apps (if there are more, would be cool to know): either ports or effect modules. I chose the second, because I wanted to create a reusable library and share it with the community, since I haven't found one that solves my problem. But I have found similar libraries (for geolocation, page-visibility and even mouse movements, which also depend on listening events on window object) and thought, that effect modules are a common way of implementing reusable behaviour, when you need to subscribe on window events

> 3. why those solutions didn't work
I assume, that ports will work perfectly, but as I mentioned, I wanted to create a reusable library. But if you have any ideas, how I can implement it without interaction with native, it would be cool

> the W3C says is no longer under active maintenance. That rings some warning bells for me!
yea, I think you have a strong argument against creating it. I understand, that community tries to create a reliable ecosystem by supervising the process of creating libraries with unstable pieces of code (but I've got familiar with it only after I tried to publish the package) and the aim is quite cool. So since the API is no longer under active maintenance, I think I can successfully use ports for my project: it's better than creating a dangerous library

But anyway, if you have any thoughts about it, let's discuss it

Thanks,
Igor

среда, 20 июня 2018 г., 22:32:19 UTC+2 пользователь Brian Hicks написал:

Brian Hicks

unread,
Jun 25, 2018, 12:35:46 PM6/25/18
to elm-dev

I assume, that ports will work perfectly, but as I mentioned, I wanted to create a reusable library. But if you have any ideas, how I can implement it without interaction with native, it would be cool

Ports are definitely the way to go here! That's the recommended way to get web APIs into Elm projects right now. Anyway, it sounds like we're on the same page here. Great!

If you have any more questions about using ports to do this, feel free to open threads in Discourse or ask on the Elm Slack. Have fun!

--
You received this message because you are subscribed to the Google Groups "elm-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-dev+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elm-dev/b2d4906d-aef3-42d3-97f9-f9b2f9f053a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages