src/Native/NativeUi.js
/**
   * Takes am Elm Native UI program implementation and turns into a React
   * component that will begin rendering the virtual tree as soon as the Elm
   * program starts running
   */
Takes am Elm Native UI program implementation and turns into a React
component that will begin rendering the virtual tree as soon as the Elm
program starts running
Takes am Elm Native UI program implementation and turns into a React component that will begin rendering the virtual tree as soon as the Elm program starts running
function makeComponent(impl, onAppReady, flags) {
    return React.createClass({
      getInitialState: function getInitialState() {
        return {};
      },
      onAppReady: onAppReady,
      componentDidMount: function componentDidMount() {
        this.eventNode = { tagger: function() {}, parent: undefined };
        this._app = _elm_lang$core$Native_Platform.initialize(
          typeof flags === 'undefined' ? impl.init : impl.init(flags),
          impl.update,
          impl.subscriptions,
          this.renderer
        );
        if (typeof this.onAppReady === "function") {
          this.onAppReady(this._app);
        }
      },
      renderer: function renderer(onMessage, initialModel) {
        this.eventNode.tagger = onMessage;
        this.updateModel(initialModel);
        return this.updateModel;
      },
      updateModel: function updateModel(model) {
        this.setState({ model: model });
      },
      render: function render() {
        return typeof this.state.model !== 'undefined' ?
          renderTree(impl.view(this.state.model), this.eventNode, 0) :
          null;
      }
    });
  }
function makeComponent ( impl , onAppReady , flags ) { return React . createClass ( { getInitialState : function getInitialState ( ) { return { } ; } , onAppReady : onAppReady , componentDidMount : function componentDidMount ( ) { this . eventNode = { tagger : function ( ) { } , parent : undefined } ; this . _app = _elm_lang$core$Native_Platform . initialize ( typeof flags === 'undefined' ? impl . init : impl . init ( flags ) , impl . update , impl . subscriptions , this . renderer ) ; if ( typeof this . onAppReady === "function" ) { this . onAppReady ( this . _app ) ; } } , renderer : function renderer ( onMessage , initialModel ) { this . eventNode . tagger = onMessage ; this . updateModel ( initialModel ) ; return this . updateModel ; } , updateModel : function updateModel ( model ) { this . setState ( { model : model } ) ; } , render : function render ( ) { return typeof this . state . model !== 'undefined' ? renderTree ( impl . view ( this . state . model ) , this . eventNode , 0 ) : null ; } } ) ; }
Takes am Elm Native UI program implementation and turns into a React
 component that will begin rendering the virtual tree as soon as the Elm
 program starts running
Takes am Elm Native UI program implementation and turns into a React component that will begin rendering the virtual tree as soon as the Elm program starts running
// There won't be a model to render right away so we'll check that it // exists before trying to call the view function