question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add an ability to hook into the Apex/Lds/CreateComponent Actions process

See original GitHub issue

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 (#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 (in onPrototypeInit, onInit hooks or locally before an actual action queueing)
  • onReject/onError - the same logic like for onResolve, but this hook provides an ablity to dive into the error handling process (#19)
  • onIncomplete - the same logic like for onReject

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
ruslan-kurchenkocommented, Jun 19, 2018

@kvizcarra, @sergey-prishchepa thank you guys for these awesome ideas!

@kvizcarra My original idea is to provide as much flexibility for users as possible. I want to provide an ability to assign listeners/handlers on two stages: prototype init and local init. In the case of the prototype - basically, it would be global listeners for all Lax components (invoked for all Lax component actions). Also, users can assign local listeners for every distinct Lax Prototype Child (invoked for certain Lax component actions) (prototype inheritance).

lax prototype

Using onPrototypeInit and onInit attributes as listeners is more native and straightforward, for me personally. The only one question is - is local Aura.Action invocation works as much synchronously as we need to assign listeners before first ApexAction/LdsAction/CreateComponentAction completed.

As you can see, the idea isn’t only an ability to assign listeners on Apex Actions. I want to add hooks for LdsAction (Lightning Data Service), CreateComponentAction and maybe even for other cases.

@sergey-prishchepa The approach with aura:method is very interesting. When I complete testing with Aura.Action, I’ll try this one and let you guys know the result. Also, I’ll try to show you how it looks like for user perspective and I hope we will find the best approach!

Thank you guys again for your contribution!

2reactions
kvizcarracommented, Jun 14, 2018
  1. Is this how onPrototypeInit and onInit will be defined?
<c:lax context="{!this}" onPrototypeInit="{!c.onLaxPrototypeInit}" onInit="{!c.onLaxInit}"/>
  1. I don’t quite understand how onResolve/onSuccess and the similar ones are defined. Will the onPrototypeInit and onInit functions be called with an object that allows us to define onResolve/onSuccess?
onLaxInit: function(lax) {
    return lax.onResolve((...) => {...});
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Use Lightning Components in Visualforce Pages
Add the Lightning Components for Visualforce JavaScript library to your Visualforce page using the <apex:includeLightning/> component.
Read more >
How to pass record id From VF page to Lightning component?
Your issue seems to be on this line action.setParams({"recordId":recordId}); in doInit function. Do you have the method newrfiopportunity in ...
Read more >
Use Lightning Web Components in External Website
Use Lightning Web Components (LWC) anywhere using Lightning out. You can either use authenticated version or can use on public Web site.
Read more >
Panel Questions Lightning Flashcards | Chegg.com
Study Panel Questions Lightning flashcards. Create flashcards for FREE and quiz yourself with an interactive flipper.
Read more >
Faith as a Principle of Action and Power
An increase of our collective faith would be a sign to the Lord that we rely on Him and trust in His power...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found