Re: [whatwg/webidl] ObservableArray without assignment (#1027)

I thought about this for a bit...and it's not so easy to answer.

On the one hand, when it's expressed as I have above, and if I'm thinking in terms of vanilla JS, I do find that code surprising. However...I don't personally write that kind of code. So, I'm not likely to be affected by it. I can see how some hard-track bugs could come from that if you don't have unit tests covering your mutation patterns. Perhaps this is what @annevk means by "people will find out quickly enough what kind of semantics the setter has".

On the other hand, after reading the IDL docs on ObservableArrays (thanks @domenic !) and referring back to @annevk's comment, it does make sense to me. I have no issues with that.

So, a bit of a mixed bag, but I'm leaning towards this not being a big issue. Perhaps potential problems can be handled with documentation? Make this very explicit not just in improvements to WebIDL, but also call this out in places like MDN and even in TypeScript d.ts. docs. At least with `FormattedText` I'm inclined to think that folks using that API are going to spend time investing in learning the best API patterns. That's not something that the average web dev is going to be messing with.

What other APIs are slated to be switched over to `ObservableArray`? What kinds of patterns in the wild are used with those APIs today?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/webidl/issues/1027#issuecomment-937110193

Received on Wednesday, 6 October 2021 20:51:21 UTC