Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
alexreardon committed May 13, 2018
1 parent d7b8c9c commit 4c43a70
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/state/middleware/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ export default (getHooks: () => Hooks, announce: Announce) => {
};
})();

const run = (store: Store, action: Action) => {
// on drag start
return (store: Store) => (next: (Action) => mixed) => (action: Action): mixed => {
if (action.type === 'INITIAL_PUBLISH') {
const critical: Critical = action.payload.critical;
const source: DraggableLocation = {
Expand All @@ -83,13 +82,15 @@ export default (getHooks: () => Hooks, announce: Announce) => {
source,
};
publisher.start(start);
next(action);
return;
}

// Drag end
if (action.type === 'DROP_COMPLETE') {
const result: DropResult = action.payload;
publisher.end(result);
next(action);
return;
}

Expand All @@ -101,30 +102,25 @@ export default (getHooks: () => Hooks, announce: Announce) => {
publisher.cancel();
}

next(action);
return;
}

// ## Perform drag updates

// No drag updates required
if (!publisher.isDragStartPublished) {
next(action);
return;
}

// Drag update required!
// TODO: should we call next first in order to get the impact of the action?
// otherwise
if (state.phase !== 'DRAGGING') {
return;
}
// Calling next() first so that we reduce the impact of the action
next(action);

if()

const state: State = store.getState();
invariant(state.phase === 'IDLE' || state.phase ===
`drag start should be published in phase ${state.phase}`);
};

return (store: Store) => (next: (Action) => mixed) => (action: Action): mixed => {
run(store, action);
next(action);
};
};

0 comments on commit 4c43a70

Please sign in to comment.