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

ref support and some style addition #63

Closed kyasu1 closed 7 years ago

kyasu1 commented 7 years ago

I have been working on the integration of react-native-maps, and it is working pretty well. In that process I realized the needs of ref property for supporting imperative methods.

The actual usage is like follows.

const _ohanhi$elm_native_ui$Native_NativeUi_MapView = function () {
  const map = require('react-native-maps');
  const maps = {};

  function refMap(el) {
    maps[el.props.id] = el;
  }

  function animateToRegion(id, region, duration) {
    return _elm_lang$core$Native_Scheduler.nativeBinding(function(callback) {
      maps[id].animateToRegion(region, duration);
      return callback(_elm_lang$core$Native_Scheduler.succeed(unit));
    });
  }

  return {
    map: map,
    refMap: refMap,
    animateToRegion: F3(animateToRegion),
  };
}();
ohanhi commented 7 years ago

Okay, this seems good to me. Thanks, @kyasu1!