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

Exception: This is not a Date object when details===true #99

Open
lroal opened this issue Nov 14, 2022 · 4 comments
Open

Exception: This is not a Date object when details===true #99

lroal opened this issue Nov 14, 2022 · 4 comments

Comments

@lroal
Copy link

lroal commented Nov 14, 2022

It throws an exception when calling a method on the date when details is true.

import onChange from 'on-change';

let proxy = onChange({ d: new Date() }, () => {}, { details: true});
proxy.d.getDate();
// throws
// file:///C:/Users/lars.roald/repos/rdb-demo/node_modules/on-change/index.js:229
//                         return Reflect.apply(target, thisArg, argumentsList);
//                                        ^

// TypeError: this is not a Date object.
//     at Proxy.getDate (<anonymous>)
//     at Object.apply ←[90m(file:///C:/Users/lars.roald/repos/rdb-demo/←[39mnode_modules/←[4mon-change←[24m/index.js:229:19←[90m)←[39m
//     at ←[90mfile:///C:/Users/lars.roald/repos/rdb-demo/←[39mchangeTest.mjs:4:9
@FPierre
Copy link

FPierre commented Feb 21, 2024

Same issue here. @lroal did you manage to find a workaround? :)

@lroal
Copy link
Author

lroal commented Feb 22, 2024

No, I don't think I did.
I turned off detail

@lroal
Copy link
Author

lroal commented Feb 22, 2024

I think I used another tool to calculate the actual difference, fast-json-patch
And just used on-change to signal a change happened.

@FPierre
Copy link

FPierre commented Feb 22, 2024

💥 wonderful idea: I actually only need to track dirty state. Way more efficient with object comparison. Thanks for the tips!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants