parent
60bd2fa6b3
commit
d52acafa21
@ -1,4 +1,4 @@
|
|||||||
import { browser } from "$app/env";
|
import { browser, dev } from "$app/env";
|
||||||
import { readable, get, derived } from "svelte/store";
|
import { readable, get, derived } from "svelte/store";
|
||||||
import { compose, applyMiddleware } from "redux";
|
import { compose, applyMiddleware } from "redux";
|
||||||
|
|
||||||
@ -6,27 +6,27 @@ import shipDux from "../shipDux/index.js";
|
|||||||
|
|
||||||
let composeEnhancers = compose;
|
let composeEnhancers = compose;
|
||||||
|
|
||||||
if (browser) {
|
if (dev && browser && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) {
|
||||||
composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;
|
composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default () => {
|
export default () => {
|
||||||
const duxStore = shipDux.createStore(undefined, (mw) =>
|
const duxStore = shipDux.createStore(undefined, (mw) =>
|
||||||
composeEnhancers(applyMiddleware(mw))
|
composeEnhancers(applyMiddleware(mw))
|
||||||
);
|
);
|
||||||
|
|
||||||
let previous;
|
let previous;
|
||||||
const state = readable(duxStore.getState(), (set) => {
|
const state = readable(duxStore.getState(), (set) => {
|
||||||
duxStore.subscribe(() => {
|
duxStore.subscribe(() => {
|
||||||
if (previous === duxStore.getState()) return;
|
if (previous === duxStore.getState()) return;
|
||||||
previous = duxStore.getState();
|
previous = duxStore.getState();
|
||||||
set(previous);
|
set(previous);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
dispatch: duxStore.dispatch,
|
dispatch: duxStore.dispatch,
|
||||||
state,
|
state,
|
||||||
shipMass: derived( state, state => state.reqs.mass )
|
shipMass: derived(state, (state) => state.reqs.mass),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user