2015-07-04 11:59:22 -07:00
|
|
|
import Rx from 'rx';
|
|
|
|
import React from 'react';
|
|
|
|
import { Router } from 'react-router';
|
|
|
|
import { history } from 'react-router/lib/BrowserHistory';
|
2015-06-17 21:04:28 -07:00
|
|
|
import debugFactory from 'debug';
|
2015-07-13 00:25:01 -07:00
|
|
|
import { Render } from 'thundercats-react';
|
2015-06-17 21:04:28 -07:00
|
|
|
|
2015-07-01 15:14:10 -07:00
|
|
|
import { app$ } from '../common/app';
|
2015-06-17 21:04:28 -07:00
|
|
|
|
|
|
|
const debug = debugFactory('fcc:client');
|
2015-07-04 11:59:22 -07:00
|
|
|
const DOMContianer = document.getElementById('fcc');
|
2015-06-17 21:04:28 -07:00
|
|
|
|
2015-07-04 11:59:22 -07:00
|
|
|
Rx.longStackSupport = !!debug.enabled;
|
|
|
|
|
2015-06-17 21:04:28 -07:00
|
|
|
// returns an observable
|
2015-07-04 11:59:22 -07:00
|
|
|
app$(history)
|
2015-07-13 00:25:01 -07:00
|
|
|
.flatMap(({ initialState, AppCat }) => {
|
|
|
|
return Render(
|
|
|
|
AppCat(),
|
|
|
|
React.createElement(Router, initialState),
|
|
|
|
DOMContianer
|
|
|
|
);
|
2015-06-29 09:50:25 -07:00
|
|
|
})
|
2015-06-17 21:04:28 -07:00
|
|
|
.subscribe(
|
2015-07-04 11:59:22 -07:00
|
|
|
() => {
|
2015-06-17 21:04:28 -07:00
|
|
|
debug('react rendered');
|
|
|
|
},
|
2015-07-04 11:59:22 -07:00
|
|
|
err => {
|
2015-06-17 21:04:28 -07:00
|
|
|
debug('an error has occured', err.stack);
|
2015-07-04 11:59:22 -07:00
|
|
|
},
|
|
|
|
() => {
|
|
|
|
debug('react closed subscription');
|
2015-06-17 21:04:28 -07:00
|
|
|
}
|
|
|
|
);
|