You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: types/phoenix_live_view/README.md
+15-9Lines changed: 15 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,26 +8,33 @@ This package contains the type definitions for the [Phoenix LiveView](https://gi
8
8
npm install --save-dev @types/phoenix_live_view
9
9
```
10
10
11
-
## BREAKING CHANGE in 0.20.0
11
+
## BREAKING CHANGE in 0.20 and 1.0
12
12
13
-
The `ViewHook` interface has been modified to better reflect the type expected by developers writing their own hooks. It used to correspond to the type of the hook object as it is constructed by the Phoenix LiveView library internally, but it included properties which are not expected for developers to provide. This required casting or commenting to make the typescript compiler happy when declaring hooks.
13
+
To preserve the actual namespaces of the phoenix_live_view Javascript modules, we distinguish
14
+
three different exports:
14
15
15
-
The new `ViewHook` interface is now correct and only expects the hook functions that developers are expected to provide given the public API. But it still provides the previous interface as `ViewHookInternal` for those who need to use it.
16
+
*`ViewHookInterface` is the interface (contract) for a LiveView hook.
17
+
*`ViewHook` is the implemented class in the phoenix_live_view module that implements
18
+
`ViewHookInterface`
19
+
*`Hook` is the generic interface that uses intersection types to let developers
20
+
add additional functionality to an instance of a hook.
16
21
17
-
Besides, and it correctly assigns the `ViewHookInternal` type to `this` when writing a hook, so properties like `el`, `viewName`, and functions like `push_event` are all there. The `ViewHook` interface can also now be used as a generic for developers who want to assign their own functions and properties to the hook object.
22
+
The `Hook` interface only expects the hook functions that developers are expected to provide given the public API.
23
+
24
+
`Hook` correctly assigns the `ViewHookInterface` interface to `this` when writing a hook, so properties like `el` and functions like `push_event` are all there. The `Hook` interface can also now be used as a generic for developers who want to assign their own functions and properties to the hook object.
0 commit comments