import * as React from 'react'; import { render } from 'react-dom'; import { AppContainer } from 'react-hot-loader'; // import our namespaced bootstrap styles import './Style/Bootstrap.less'; // import framework API surface import './webrx-react'; // import the App view and view model import { AppView, AppViewModel } from './Components'; // import the demos import './Components/Demo'; // grab the DOM entry point const container = document.getElementById('app'); let app: AppViewModel; function renderApp(newViewModel = false) { const Components: { AppView: typeof AppView; AppViewModel: typeof AppViewModel; } = require('./Components'); app = newViewModel || app == null ? new AppViewModel(true, true, true) : app; return ( {'Powered by '} TypeScript {', '} React {', and '} RxJS } /> ); } function renderAppContainer(newViewModel = false): any { if (WEBPACK_DEV_SERVER) { return {renderApp(newViewModel)}; } return renderApp(newViewModel); } if (container) { render(renderAppContainer(), container); } if (WEBPACK_DEV_SERVER) { if (module.hot) { module.hot.accept( ['./webrx-react', './Components', './Components/Demo'], ids => { const newViewModel = ids.some( x => String.isString(x) && x.toLowerCase().indexOf('viewmodel') >= 0, ); render(renderAppContainer(newViewModel), container); }, ); } }