question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Introduce support for Symbol named observable properties

See original GitHub issue

Welcome to MobX. Please provide as much relevant information as possible!

I have a:

  1. Question: Feel free to just state your question. For a quick answer, there are usually people online at our Gitter channel
  2. Documentation improvement. Please don’t open an issue but create a PR instead!
  3. Issue:
  • Provide error messages including stacktrace
  • Provide a minimal sample reproduction. Create a reproduction based on this sandbox
  • Did you check this issue wasn’t filed before?
  • Elaborate on your issue. What behavior did you expect?
  • State the versions of MobX and relevant libraries. Which browser / node / … version?
  1. Idea:
  • What problem would it solve for you?
  • Do you think others will benefit from this change as well and it should in core package (see also mobx-utils)?
  • Are you willing to (attempt) a PR yourself?

Please tick the appropriate boxes. Feel free to remove the other sections.

Please be sure to close your issues promptly.

What

error 'set' on proxy: trap returned falsish for property 'Symbol(count)' threw when using Symbol as key in an observable,

How to reproduce

Edit oj8w3l77oz

  1. click the add button in normal section works fine
  2. click the add button in symbol section broken 😦

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

5reactions
urugatorcommented, Nov 16, 2018

Mobx ignores non-enumerable props (like symbols) in observable/extendObservable. The symbol is firstly introduced to the observable object during the assignment (in incSymbol). Mobx4 doesn’t support dynamic keys, so the standard JS behavior (new non-observable property is added to object) takes place, therefore no error. In Mobx5 proxy handler returns false for non-string keys, resulting in TypeError.

If Symbols where supported, could it conflict with current or future well-known symbols like: Symbol.iterator, Symbol.toStringTag, etc. ?

I don’t think so. Symbols are accessible via Object.getOwnPropertySymbols(), returning an empty array on empty objects. The argument passed to observable/extendObservable represents simple property list - not an arbitrary “smart” object (eg an object implementing a well known symbol). So if there is a symbol, it’s introduced by user and should be made observable imho (no matter what symbol it is, similary to providing toString or valueOf).

2reactions
mweststratecommented, Jun 4, 2019

Released as 4.10.0 / 5.10.0. Thanks @loklaan !

Read more comments on GitHub >

github_iconTop Results From Across the Web

Classifying Objects Based on their Observable Properties
Students are introduced to the idea that objects and materials have certain “properties”or “characteristics” that can be used to describe them.
Read more >
Observable - SimBiology - MathWorks
An observable object is a mathematical expression that lets you perform post-simulation calculations.
Read more >
STIX™ Version 2.1 - OASIS Open
This document provides a language for expressing cyber threat and observable information. It defines the concepts and overall structure of the STIX ...
Read more >
Symbol - JavaScript - MDN Web Docs
Chrome Edge Symbol Full support. Chrome38. Toggle history Full support. Edge12. footnote... @@toPrimitive Full support. Chrome47. Toggle history Full support. Edge15. Toggle... Symbol() constructor Full support....
Read more >
1.3: Properties of Matter - Chemistry LibreTexts
Although mass and volume are both extensive properties, their ratio is an important intensive property called density (ρ).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found