diff --git a/src/index.js b/src/index.js index 25d4270..4c27729 100644 --- a/src/index.js +++ b/src/index.js @@ -6,8 +6,6 @@ import ReactDOM from 'react-dom'; import { Provider as ReduxProvider } from 'react-redux'; import { Router, browserHistory } from 'react-router'; -import webFont from 'webfontloader'; - import { factory as userFactory } from 'components/user/factory'; import { IntlProvider } from 'components/i18n'; import routesFactory from 'routes'; @@ -15,6 +13,7 @@ import storeFactory from 'storeFactory'; import bsodFactory from 'components/ui/bsod/factory'; import loader from 'services/loader'; import logger from 'services/logger'; +import font from 'services/font'; logger.init({ sentryCdn: window.SENTRY_CDN @@ -22,27 +21,13 @@ logger.init({ import dispatchBsod from 'components/ui/bsod/dispatchBsod'; // TODO: remove after tests -import dispatchBsod from 'components/ui/bsod/dispatchBsod'; // TODO: remove after tests - const store = storeFactory(); bsodFactory(store, stopLoading); -const fontLoadingPromise = new Promise((resolve) => - webFont.load({ - classes: false, - active: resolve, - inactive: resolve, // TODO: may be we should track such cases - timeout: 2000, - custom: { - families: ['Roboto', 'Roboto Condensed'] - } - }) -); - Promise.all([ userFactory(store), - fontLoadingPromise + font.load(['Roboto', 'Roboto Condensed']) ]) .then(() => { ReactDOM.render( diff --git a/src/services/font.js b/src/services/font.js new file mode 100644 index 0000000..44633bd --- /dev/null +++ b/src/services/font.js @@ -0,0 +1,22 @@ +import webFont from 'webfontloader'; + +export default { + /** + * @param {array} families + * + * @return {Promise} + */ + load(families = []) { + return new Promise((resolve) => + webFont.load({ + classes: false, + active: resolve, + inactive: resolve, // TODO: may be we should track such cases + timeout: 2000, + custom: { + families + } + }) + ); + } +};