Pricing Blog

is it possible to update a variable inside a component without using an attribute

  • jehex-1376110650085871656

    Jehex

    2 months ago

    Hi there, sorry if my question is confusing but Im facing this problem sometimes, probably obvious to fix

    I have one variable ( tokens ) inside a component who is set by a context variable ( screenshot )
    The context variable get all user infos, on this example Im using the context variable for get the current tokens amount of the user
    Now, I would like to refresh the variable of the child component each time the user click on a button inside the PARENT component ( which minus 1 the tokens amount to the user table ) , the parent and the child component don't share any attributes, how can I update the variable tokens inside the child component without using any attributes for the on attributes change event.

    Thanks
    1376110650534658078-Untitled.png
  • paspom-1376113610740334692

    Pascal

    2 months ago

    this should be done as a formula
    try the same thing as a formula and it will work 😊
  • jehex-1376114585563566160

    Jehex

    2 months ago

    Hi, but the child component will be not dynamically updated no ?
  • paspom-1376114685648175115

    Pascal

    2 months ago

    I mean the child
  • the very variable you here show us
  • the variable right here in the screenshot must be a formula
  • and then the value-change of the parent will immediately be tangible in that calculation
  • paspom-1376115405105528944

    Pascal

    2 months ago

    but, just an assumption, if you work with backend data (currentUser) – you should could also directly pull from the api into the formula for context
    in general, there is no need to store it in a variable, unless you have some kind of local storage rule or similar things
  • jehex-1376116442478415942

    Jehex

    2 months ago

    create the formula directly into the parent then pass it into the child as attribute ?
  • paspom-1376117524583940188

    Pascal

    2 months ago

    I assume you want to add values together in this child
    out of values
    that you get from the parent's variable
    in order to have it "immediately" you need to do the "add" as a formula, not as a variable
    a variable needs a workflow in order to be refreshed
  • If you want we can do a quick call, its often more efficient and swift for both of us
  • jehex-1376120109151686656

    Jehex

    2 months ago

    the parent component and child not really share values, inside the parent component I minus the number of tokens from the DB ( user_record ) and the child show the updated number of tokens in realtime
    1376120108900024421-Untitled.png
  • jehex-1376120717816365158

    Jehex

    2 months ago

    at this moment the component need to be reload or I need to use an " useless " attribute for refresh dynamically the tokens values trought attribute on change event
  • paspom-1376121362472501392

    Pascal

    2 months ago

    because of this you need to do formulas instead of variables
  • jehex-1376121846235398154

    Jehex

    2 months ago

    yep, I set the formula inside the child component ( so as you said instead of create a variable I set a formula who get the values from the context variable )
  • but the child component dont get updated dynamically
  • paspom-1376122939006783589

    Pascal

    2 months ago

    I cant follow through your thoughts
    we can do a quick call (costs you nothing) I could help you first hand
    but maybe someone else here can hop in
  • jehex-1376123325541253150

    Jehex

    2 months ago

    I forget to mention but I show the current value of the tokens on a text html element, basically what I need is to just when the button is clicked on the parent component -> it's updated directly the value of on this txt element inside the child element ( throught the formula or the variable previously )
  • jehex-1376123472132050964

    Jehex

    2 months ago

    at this moment I cannot but I will try to figure out this issue and when Im available for a call I will let you know, thanks for your time
  • paspom-1376123734229778452

    Pascal

    2 months ago

    absolutely
    have patience with yourself
    practice, practice, practice