Aurelia Store, immerjs and objects

I tried to set invokeGetters to true at the begining of the function and the solution you described and sadly, none of them worked for me on my test app. I got the same error with both tries: TypeError: this.getArrayObserver(...) is undefined from aurelia-binding.js:4814.

1 Like

This relates to your bindable decorator right? Or did you talk about the original first posts sample?

1 Like

No, I removed all that to use the standard decorator.

1 Like

I’ve just tried the basic counter inc Sample and it worked with the mentioned fix. Couldnt see any console errors any longer. Maybe you can share your articles sample so we can tweak that a bit together to see where the issue is

1 Like

I updated the code on the gitlab repo. I included mocked data to make the app usable as is.

Steps to reproduce issue:

  1. git clone https://gitlab.com/Jenselme/aurss.git
  2. git checkout feat/use-immerjs-with-aurelia-store
  3. yarn
  4. yarn start
  5. Open http://localhost:8080/

Now if you click on Mark as read, you’ll get Unhandled rejection Error: Immer drafts cannot have computed properties before the modification on immerjs and TypeError: this.getArrayObserver(...) is undefined after.

If you need anything else, let me know.

1 Like

@Jenselme I cloned this repo and I get the same as you concerning the array observer.

I tried a lot of different things as binding to an array that is modified by immer is working in my app. Finally, I commented out
if.bind=“articles.length === 0”>No unread article.
in home.html.

No more error. So it’s the if.bind on the articles causing the issue, not the repeat.for.

Is this news to you?

1 Like

well that might be actually a sideeffect from dropping the observers.
If in @Jenselme’s example instead of commenting out what you mentioned @swalters I do fixup the subscription in home.ts -> bind to be

.subscribe(((articles) => { this.articles = [...articles]; }));

it’s all good, except that you still get all articles, not sure if business logic is wrong here or again another issue.

1 Like

@zewa666 but it was still bound to articles in the repeat-for. I only removed 1 of 2 template items bound to articles. It’s a weird error for sure.

1 Like

Yeah but it seems there is a logical issue because I cant find any location where it filters to show only read===false.

1 Like

Yes, it is. I didn’t try this. Thanks.

I don’t filter read articles from this array. I want to display them as read (ie faded out) in the interface, not directly remove them. I guess it’s my variable name which is poorly chosen.

@swalters @zewa666 thanks for looking into this!

1 Like