I'm curious to know if ES6 class methods and other callback functions are officially supported by the r()
function, or if they only work by coincidence.
I'm asking because the ReactiveProxy<T>
type isn't callable, which means you get warnings/errors when using TS, but not when using JS. It also appears to work fine, so I'm not sure if it is intended behavior or not.
Here's an example of what I mean with an ES6 class:
class Foo {
public mutateState(): void {
// mutates internal class state here
}
}
// ...
const data = r(new Foo())
data.mutateState(); // <-- This will get a Typescript warning/error
It yields the following warning/error:
Type '
ReactiveProxy<() => void>
' has no call signatures.
The same thing happens if I pass a function definition into the r()
function instead of a new class (i.e. r({greet: () => alert('hi')})
)
Like I said, though, having it mutate its own data works as expected (and even causes re-renders when placed in a template) if I tell Typescript to ignore the issue.
If it's intended to work, then maybe the ReactiveProxy<T>
type needs a way to be callable?
If passing mutators into the r()
method isn't intended, it would be useful to have it added to the docs.
Owner Name | justin-schroeder |
Repo Name | arrow-js |
Full Name | justin-schroeder/arrow-js |
Language | TypeScript |
Created Date | 2022-11-08 |
Updated Date | 2023-03-28 |
Star Count | 1240 |
Watcher Count | 21 |
Fork Count | 22 |
Issue Count | 7 |
Issue Title | Created Date | Updated Date |
---|