fix(updates): Fix learn -> server communication
This commit is contained in:
@@ -1,41 +0,0 @@
|
||||
import { Observable } from 'rxjs';
|
||||
import Fetchr from 'fetchr';
|
||||
|
||||
function callbackObserver(observer) {
|
||||
return (err, res) => {
|
||||
if (err) {
|
||||
return observer.error(err);
|
||||
}
|
||||
|
||||
observer.next(res);
|
||||
return observer.complete();
|
||||
};
|
||||
}
|
||||
|
||||
export default function servicesCreator(options) {
|
||||
const services = new Fetchr(options);
|
||||
|
||||
return {
|
||||
readService$({ service: resource, params = {} }) {
|
||||
return Observable.create(observer =>
|
||||
services
|
||||
.read(resource)
|
||||
.params(params)
|
||||
.end(callbackObserver(observer))
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// createService$({ service: resource, params, body, config }) {
|
||||
// return Observable.create(observer => {
|
||||
// services.create(
|
||||
// resource,
|
||||
// params,
|
||||
// body,
|
||||
// config,
|
||||
// callbackObserver(observer)
|
||||
// );
|
||||
// return Subscription.create(() => observer.dispose());
|
||||
// });
|
||||
// }
|
@@ -4,26 +4,19 @@ import { createStore as reduxCreateStore, applyMiddleware } from 'redux';
|
||||
import createSagaMiddleware from 'redux-saga';
|
||||
import { createEpicMiddleware } from 'redux-observable';
|
||||
|
||||
import servicesCreator from './createServices';
|
||||
import { _csrf } from './cookieValues';
|
||||
|
||||
import rootEpic from './rootEpic';
|
||||
import rootReducer from './rootReducer';
|
||||
import rootSaga from './rootSaga';
|
||||
import { isBrowser } from '../../utils';
|
||||
|
||||
const serviceOptions = {
|
||||
context: _csrf ? { _csrf } : {},
|
||||
xhrPath: '/external/services',
|
||||
xhrTimeout: 15000
|
||||
};
|
||||
const clientSide = isBrowser();
|
||||
|
||||
const sagaMiddleware = createSagaMiddleware();
|
||||
const epicMiddleware = createEpicMiddleware({
|
||||
dependencies: {
|
||||
window: typeof window !== 'undefined' ? window : {},
|
||||
location: typeof window !== 'undefined' ? window.location : {},
|
||||
document: typeof window !== 'undefined' ? document : {},
|
||||
services: servicesCreator(serviceOptions)
|
||||
window: clientSide ? window : {},
|
||||
location: clientSide ? window.location : {},
|
||||
document: clientSide ? document : {}
|
||||
}
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user