Skip to content

Commit

Permalink
Refactor: lifted up a couple of shared nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
monfera committed Feb 18, 2019
1 parent d3d5137 commit 9f3d656
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 20 deletions.
9 changes: 9 additions & 0 deletions x-pack/plugins/canvas/public/lib/aeroelastic/dag_start.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,13 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { select } from './select';
import { getPrimaryUpdate, getScene } from './layout_functions';

export const state = d => d;
/**
* Scenegraph update based on events, gestures...
*/

export const scene = select(getScene)(state);
export const primaryUpdate = select(getPrimaryUpdate)(state);
12 changes: 1 addition & 11 deletions x-pack/plugins/canvas/public/lib/aeroelastic/gestures.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
*/

import { select } from './select';
import { state } from './dag_start';
import { getScene } from './layout_functions';
import { primaryUpdate, scene } from './dag_start';

// Only needed to shuffle some modifier keys for Apple keyboards as per vector editing software conventions,
// so it's OK that user agent strings are not reliable; in case it's spoofed, it'll just work with a slightly
Expand All @@ -20,15 +19,6 @@ const appleKeyboard = Boolean(
window.navigator.userAgent.match('Macintosh|iPhone|iPad')
);

/**
* Selectors directly from a state object
*
* (we could turn gesture.js into a factory, with this state root - primaryUpdate - being passed...)
*/

const scene = select(getScene)(state);
const primaryUpdate = select(state => state.primaryUpdate)(state);

const gestureStatePrev = select(
scene =>
scene.gestureState || {
Expand Down
9 changes: 1 addition & 8 deletions x-pack/plugins/canvas/public/lib/aeroelastic/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ import {
getRestateShapesEvent,
getRotationAnnotations,
getRotationTooltipAnnotation,
getScene,
getSelectedPrimaryShapeIds,
getSelectedShapeObjects,
getSelectedShapes,
Expand All @@ -65,16 +64,10 @@ import {
getShapes,
getSnappedShapes,
getTransformIntents,
primaryUpdate,
resizeAnnotationsFunction,
} from './layout_functions';
import { state } from './dag_start';

/**
* Scenegraph update based on events, gestures...
*/

const scene = select(getScene)(state);
import { primaryUpdate, scene } from './dag_start';

export const shapes = select(getShapes)(scene);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1205,7 +1205,7 @@ export const getCursor = (config, shape, draggedPrimaryShape) => {
/**
* Selectors directly from a state object
*/
export const primaryUpdate = state => state.primaryUpdate;
export const getPrimaryUpdate = state => state.primaryUpdate;

export const getSelectedShapesPrev = scene =>
scene.selectionState || {
Expand Down

0 comments on commit 9f3d656

Please sign in to comment.