-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[editor] Generalise API #2
Comments
…ction This means Redux events are serializable now. Also a step towards edit policies, as there's less domain-specific logic in tools. A step towards #2
We are here 🤔 I do not know for the life of me what's the point in edit policies returning an array of actions that are then dispatched by the tools. (A day later) 🤔 Found the GEF source
🤔 Here is some code: // IncrementDecrementAction.java
private Command getCommand() {
List editparts = getSelectedObjects();
CompoundCommand cc = new CompoundCommand();
cc.setDebugLabel("Increment/Decrement LEDs");//$NON-NLS-1$
for (int i=0; i < editparts.size(); i++) {
EditPart part = (EditPart)editparts.get(i);
cc.add(part.getCommand(request));
}
return cc;
}
public void run() {
execute(getCommand());
} 🤔 Then in the base class: protected void execute(Command command) {
if (command == null || !command.canExecute())
return;
getCommandStack().execute(command);
} 🤔 So it all seems as if in order to have this base class handling. |
🤔OK, so we are going provide Question is how? Edit Policies APIOptions: Thunk APIConclusion: OK, but inverted thunk is better. That is: (params) => (dispatch, getState) => {} or in a more compact form: (params) => store => {} Familiar. Notice that we have thunks, like So MiddlewareConclusion: 👎 store => next => action But:
Inverted thunkConclusion: 👍 store => params => {} or: (dispatch, getState) => params => This is useful for compound policies (like drags). Where instead of: connection: {
start: event => dispatch => {},
drag: event => dispatch => {},
end: event => (dispatch, getState) => {},
}, We could:
The difference between the former and the latter is that as far as extracting common policies is concerned, the latter forces reuse of all three sub-policies, whereas with the former you don't have this limitation. 👱♀️Will you ever want to reuse one but not the other?
GlobalConclusion: 👎 We could apply const editPolicies = store => ({
...
}) This will allow Splitting Edit PoliciesCurrently the connection edit policy in chip-editor does 3 things:
We want these split. Also note that an edit policy might need some context between it subs. For example: connection: () => {
let beforeState;
return {
start: ...
drag: ...
end: ...
} So if we are to split the 3 above we get:
▶ All this kind of mean that an the inverted thunk api is the right one. |
First attempt at compound edit policy: connection: [
// Connection
(dispatch, getState) => ({
start: event => {},
drag: event => {},
end: event => {}
}),
// Mark as valid
(dispatch, getState) => ({
start: event => {},
end: () => {}
}),
// Undo
(dispatch, getState) => {
let beforeState;
return {
start: () => {},
end: event => {}
};
}
] The issue is that the connection policy adds the connection and then in undo In addition, What's interesting is that if we don't have All this seems to suggest that "reusable" edit policies won't have the In turn this suggests that the parent edit policy should be able to do some work before returning the (partly applied) subs. So this: connection: [
(dispatch, getState) => {
let beforeState;
return {
start: () => {},
end: event => {}
};
}
] Becomes: connection: (dispatch, getState) => {
// Some processing here
return [
(dispatch, getState) => {
let beforeState;
return {
start: () => {},
end: event => {}
};
}
];
} Which will then become: const undoConnectionPolicy = isValidConnection => (dispatch, getState) => {
let beforeState;
return {
start: () => {},
end: event => {}
};
};
const port = {
connection: (dispatch, getState) => {
const isValidConnection = () => {};
return [undoConnectionPolicy(isValidConnection)];
}
}; Or: const undoConnectionPolicy = (dispatch, isValidConnection) => {
let beforeState;
return {
start: () => {},
end: event => {}
};
};
const port = {
connection: (dispatch, getState) => {
const isValidConnection = () => {};
return [undoConnectionPolicy(dispatch, isValidConnection)];
}
}; |
Undo
Probably undo needs to be in the command/tools, but in the case of connection or move - how do we know if something has changed? |
Currently most of the editor work was done on
chip-editor
and the whole implementation is very domain specific. We need to start defining the (generic) editor API.Current Design
The flow for tools/pointer events is like so:
For example (selection tool):
Goal
We want both tools and actions to be generic, and some domain-specific mapper between them:
GEF's EditPolicies
EditPolicies
take a request from a tool and return a command (to modify the model).Where are meta's used?
Reducers
Selections
markValidPorts
isValidConnection()
Plan
The text was updated successfully, but these errors were encountered: