Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR creates a new package
@finos/perspective-react
, a dedicated Perspective integration library for the React JavaScript framework.This abstraction is intended to be lightweight over Perspective's browser native API, with the only design goal being to lessen the impedance mismatch between Perspective's internally stateful (and imperative) Custom Element API, and React's functional design. More relevant than the new
PerspectiveVIewer
React component, is the underlying API changes to the<perspective-viewer>
Custom Element which makes integration possible:Table::delete
,View::delete
,Client::terminate
andHTMLPerspectiveViewerElement::delete
are now fully destructive, and calling any method on their objects afterwards will throw a definitive null pointer dereference error. Calling these methods unrecoverably & completely deallocates their associated objects, not just their handles.Table
returned byClient::open_table
) can be deallocated but not deleted remotely viatable.free()
in JavaScript (Python does not leak handles).Table::delete
has a new options parameter, which has a single boolean propertylazy
, which defers the deletion until theView
count for thisTable
naturally reaches zero. Be careful not to overuse this - it is easy to "leak"Table
by usinglazy
without remembering to cleanup allHTMLPerspectiveViewerElement
(and henceView
objects) which use it, effectively leaking theTable
without a warning. Thelazy
property just makes ordering this method call easier in React where it is difficult to signal when all dependencies Custom Elements have been destroyed byReact.useEffect
destructors (which may be nested opaquely in the component graph) - it does not absolve you from callingView::delete
orHTMLPerspectiveViewerElement::delete
on dependencies inReact.useEffect
in the first place.HTMLPerspectiveViewerElement::eject
is the reciprocal ofHTMLPerspectiveViewerElement::load
, removing any loadedTable
and reverting the element to its initial state. This is different fromHTMLPerspectiveViewerElement::delete
, which deallocates the element entirely (and can't be recovered).HTMLPerspectiveViewerElement::load
is now equivalent toHTMLPerspectiveViewerElement::reset
if theTable
is already loaded (has the sameClient
instance and table name.Drive-by changes:
pyo3
andwasm_bindgen
were struggling to handle these, and even where it worked it was quirky. This change, for example, makes@finos/perspective
TypeScript types to have their APIs get proper tsdocs. Some ancillary build steps were pruned as well.