-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add an ability to hook into the Apex/Lds/CreateComponent Actions process #21
Comments
@kvizcarra, @sjurgis, could you guys comment on that and give me any feedback. |
<c:lax context="{!this}" onPrototypeInit="{!c.onLaxPrototypeInit}" onInit="{!c.onLaxInit}"/>
onLaxInit: function(lax) {
return lax.onResolve((...) => {...});
} |
If you have ideas or propositions, please share them here. |
Try to define an attribute type as <aura:attribute name="onPrototypeInit" type="Object"/> Then in the var onPrototypeInit = cmp.get('v.onPrototypeInit');
onPrototypeInit.setCallback(this, function(response) { ... });
$A.enqueueAction(onPrototypeInit) Then in the consumer's action passed to <c:lax context="{!this}" onPrototypeInit="{!c.onLaxPrototypeInit}"/> Consumer's action in the controller: onLaxPrototypeInit: function (component, event, helper) {
return {
predefinedProp1: '',
predefinedProp2: '',
predefinedMethod: function(arguments) {
// some logic here
},
...
};
}, And then in the |
@sergey-prishchepa @ruslan-kurchenko The MyComponent.cmp ...
<c:laxWrapper>
<c:lax context="{!this}"/>
</c:laxWrapper>
... laxWrapper.cmp <aura:handler name="laxEvent" event="c:laxEvent" action="{!c.onLaxEvent}" includeFacets="true"/> laxWrapperController.js ({
onLaxEvent: function(component, event, helper) {
const params = event.getParam('params');
switch (event.getParam('action')) {
case 'onResolve':
params.callback({
...params.lax,
onResolve: (...) => {...}
});
break;
}
}
}) |
@kvizcarra you proposed a good idea, but I can't say that solution is 'little similar' :) It requires to create an additional component @ruslan-kurchenko ConsumerConponent.cmp <c:lax context="{!this}"/>
<aura:method name="onLaxPrototypeInit"/> ConsumerConponentController.js onLaxPrototypeInit: function (component, event, helper) {
return { ... }; // the predefined object
}, In the var prototypeInitObject = context.onLaxPrototypeInit ? context.onLaxPrototypeInit() : null; |
@kvizcarra, @sergey-prishchepa thank you guys for these awesome ideas! @kvizcarra Using As you can see, the idea isn't only an ability to assign listeners on Apex Actions. I want to add hooks for @sergey-prishchepa Thank you guys again for your contribution! |
@sergey-prishchepa @kvizcarra @scottbcovert @rsoesemann Hey folks! First of all, there are two branches that contain the hooks implementation:
My own cons/pros:
Guys, it is my own thoughts. Could you test these two approaches and give me a feedback, please. P.S. |
Released in v1.2.4 |
@ruslan-kurchenko Sorry to be commenting on this after the fact, but just went through the commit and it looks like you went with the |
@scottbcovert, not a problem at all. I totally agree with you. |
Define an ability to assign "hook" functions
List of hooks:
onPrototypeInit
- an attribute on the Lax component. The user will be able to assign function that executes only once. It will be nice to use to define global settings.onInit
- an attribute on the Lax component. It is local hook to assigne a function that executes when an actual Lax component object created. Due to internal Lax architecture, the system has Lax Prototype object and a list of local Lax objects that inherit the functionality from the Prototype object.onResolve/onSuccess
- a function to "decorate/change" a resolved value (Add a flag to automaticallyJSON.parse
response from Apex #20) that went from the server. It will has a default implementation (empty function or not, investigating...) and a user can assign his custom function implementation (inonPrototypeInit
,onInit
hooks or locally before an actual action queueing)onReject/onError
- the same logic like foronResolve
, but this hook provides an ablity to dive into the error handling process (Add error parser / normaliser #19)onIncomplete
- the same logic like foronReject
The text was updated successfully, but these errors were encountered: