ManuelDeLeon / viewmodel

MVVM for Meteor
https://viewmodel.org
MIT License
205 stars 23 forks source link

Strange behavior on properties. #271

Open tomyo opened 8 years ago

tomyo commented 8 years ago

I'll just paste the self-explained code below: P.S. I tried setting a new value instead of using reset(), same strange behavior.

Template.cartItem.viewmodel
  shippingPrice: undefined
  updateShippingPrice: ->
    if @ship() and not @outOfStock()
      Meteor.call 'calculateShipingPrice', @productId(), (error, result) =>
        if error
          FF.helpers.showInternalError error
        else
          @shippingPrice result
    else
      @shippingPrice.reset()
      @shippingPrice()  # FIXME: Why doesn't work without this line?
                        # shippingPrice doesn't update if I don't ask for it's value now
ManuelDeLeon commented 8 years ago

I don't understand the problem. Please make a minimal repro, preferably without Meteor calls and anything not germane to the problem.

Thanks.

On Sep 2, 2016 1:22 PM, "Tomas Hayes" notifications@github.com wrote:

I'll just paste the self-explained code below: P.S. I tried setting a new value instead of using reset(), same strange behavior.

Template.cartItem.viewmodel shippingPrice: undefined updateShippingPrice: -> if @ship() and not @outOfStock() Meteor.call 'calculateShipingPrice', @productId(), (error, result) => if error FF.helpers.showInternalError error else @shippingPrice result else @shippingPrice.reset() @shippingPrice() # FIXME: Why doesn't work without this line?

shippingPrice doesn't update if I don't ask for it's value now

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ManuelDeLeon/viewmodel/issues/271, or mute the thread https://github.com/notifications/unsubscribe-auth/AED31qdnOFh1-bR_GTcvYsF1QGpVni3Lks5qmHU-gaJpZM4J0AZu .