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

Allow accessing app (and thus ports) via callback to start #69

Closed ahstro closed 7 years ago

ahstro commented 7 years ago

Disclaimer: If this exists and I just blatantly missed it, sorry. I've spent way too much time trying to figure out where the ports might be hidden, and finally descended into the git history of elm-native-ui and found some remnants of a callback that I decided to piece "back" together. If this doesn't make sense or is superfluous, just close and please, tell me where ports are 😅

Allow passing a callback function to start that is, upon app initialization, called with the app instance as a single argument. This lets you, e.g., set up ports with something like this:

const component = Elm.Main.start(app => {
  app.ports.something.subscribe(doStuff)
})
ohanhi commented 7 years ago

Brilliant, thanks so much!