ohanhi / elm-native-ui

[CLOSED] Experiment: mobile apps in Elm using React Native.
BSD 3-Clause "New" or "Revised" License
1.54k stars 76 forks source link

If we have ports why not flags... #72

Closed kyasu1 closed 7 years ago

kyasu1 commented 7 years ago

The title says about adding Flags support, but actually I needed a way to pass a JS props object to native JS functions through Elm program without knowing details, that means no decoding and encoding. unsafeProgramWithFlags is pretty useful for such case though no guarantee of type safety. I will show you my usage if necessary.

ohanhi commented 7 years ago

Hi @kyasu1, thanks for the contribution! I'd prefer to leave off the unsafe variant, if possible. Why is it necessary in your opinion?

kyasu1 commented 7 years ago

Hi @ohanhi, thank you for reviewing and taking your time. After thinking carefully, I realized that having unsafe variant is a kind of cheating and it should not be exposed in the public API as you mentioned. With proper encoder/decoder and programWithFlags, we can pass JS object through Elm code to JS native functions, though writing decoders is still a pain for me >.< Anyway, removed the unsafe code and pushed again.

ohanhi commented 7 years ago

Awesome, thanks!