Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isWrappable(new Class()) return false #1661

Closed
Reinhard2019 opened this issue Mar 30, 2023 · 3 comments
Closed

isWrappable(new Class()) return false #1661

Reinhard2019 opened this issue Mar 30, 2023 · 3 comments
Labels
wontfix This will not be worked on

Comments

@Reinhard2019
Copy link

Describe the bug

In this issue: #19
@ryansolid Decided to only wrap plain Objects and Arrays like MobX.

But i think a class object also should be wrap.

What do you think?

Your Example Website or App

https://stackblitz.com/edit/typescript-mkiunp?file=index.ts

Steps to Reproduce the Bug or Issue

class Obj {}
console.log('new Obj():', isWrappable(new Obj()))

Expected behavior

return true

Screenshots or Videos

image

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]
  • Version: [e.g. 91.1]

Additional context

No response

@ryansolid
Copy link
Member

ryansolid commented Mar 30, 2023

No this is by design. Is wrappable false means that it can only wrap it atomically instead of each property. We did this to avoid wrapping built in classes like Date, Regexp, HTMLElement. And things like Set and Map which could be wrapped differently depending on intent. The original issue explains how this is a much easier identification model than trying to exempt specific classes.

@ryansolid ryansolid added the wontfix This will not be worked on label Mar 30, 2023
@Reinhard2019
Copy link
Author

No this is by design. Is wrappable false means that it can only wrap it atomically instead of each property. We did this to avoid wrapping built in classes like Date, Regexp, HTMLElement. And things like Set and Map which could be wrapped differently depending on intent. The original issue explains how this is a much easier identification model than trying to exempt specific classes.

But when i use createStore({ obj: new Obj() }),store.obj will not be monitored.

Can you give me an escape window?

@Reinhard2019
Copy link
Author

@ryansolid Do you think it is possible to add a symbol to solve this problem? Like this:
image
If you think it's ok, i will commit a pr. thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants