blaze icon indicating copy to clipboard operation
blaze copied to clipboard

Missing resolve properties when handle #with with promise

Open DblK opened this issue 1 year ago • 4 comments

Blaze: 3.0.0 (2.6.1 worked fine but no promise at that time) Meteor: 3.0.2

Since my migration of my application to Meteor 3.0, I had few bugs and the one I had a hard time to figure out was with the helper #with in conjunction with a helper with promise.

I expect #with to work like a #if but it not quite there. The code go through the #with once the promise is resolve however it can not resolve the variable inside.

Let's say, I have a helper returning a promise with :

async computed() {
   const mycall = await something();

  return mycall; // {a: 1, b: 2, c: 3} || null
}

If I use within blaze :

{{#with computed}}
  {{a}} // not working
  {{computed.a}} // working
{{/with}}

But it defeat my use case of using the with helper.

DblK avatar Sep 04 '24 07:09 DblK

Thank you @DblK for the report. Can you confirm it already happens in Blaze 2.9.0?

jankapunkt avatar Sep 05 '24 06:09 jankapunkt

@DblK I also think it's currently not as easy to reolve under the hood as we'd like it to be. Can you think of using the Async States instead? → https://www.blazejs.org/api/spacebars#Async-States

jankapunkt avatar Sep 05 '24 06:09 jankapunkt

I think it'd actually be trivial now, as it's very similar to how #if works (https://github.com/meteor/blaze/pull/424). I encourage someone to try it themselves, but I can also do that somewhere next week.

radekmie avatar Sep 05 '24 06:09 radekmie

Thank you @DblK for the report. Can you confirm it already happens in Blaze 2.9.0?

No I can not. I updated the whole app from my previous version to meteor 3.

@DblK I also think it's currently not as easy to reolve under the hood as we'd like it to be. Can you think of using the Async States instead? → https://www.blazejs.org/api/spacebars#Async-States

I might be able but that means I have to redo/check my whole app and I have too many screens so it does not seems a good solution for me.

I think it'd actually be trivial now, as it's very similar to how #if works (#424). I encourage someone to try it themselves, but I can also do that somewhere next week.

Thanks for pointing out. My guess was that it should be similar to #if so I will have a look at it.

DblK avatar Sep 05 '24 08:09 DblK