mobx#comparer TypeScript Examples
The following examples show how to use
mobx#comparer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KubeResourceChart.tsx From lens-resource-map-extension with MIT License | 6 votes |
async componentDidMount() {
this.setState(this.state);
this.registerStores();
await this.loadData();
this.displayChart();
const fg = this.chartRef.current;
//fg?.zoom(1.2, 1000);
fg?.d3Force('link').strength(2).distance(() => 60)
fg?.d3Force('charge', d33d.forceManyBody().strength(-60).distanceMax(250));
fg?.d3Force('collide', d3.forceCollide(40));
fg?.d3Force("center", d3.forceCenter());
const reactionOpts = {
equals: comparer.structural,
}
const { object } = this.props
const api = Renderer.K8sApi.apiManager.getApiByKind(object.kind, object.apiVersion);
const store = Renderer.K8sApi.apiManager.getStore(api);
this.disposers.push(reaction(() => this.props.object, (value, prev, _reaction) => { value.getId() !== prev.getId() ? this.displayChart() : this.refreshChart() }));
this.disposers.push(reaction(() => this.podsStore.items.toJSON(), (values, previousValue, _reaction) => { this.refreshItems(values, previousValue) }, reactionOpts));
this.disposers.push(reaction(() => store.items.toJSON(), (values, previousValue, _reaction) => { this.refreshItems(values, previousValue) }, reactionOpts));
}
Example #2
Source File: DataTable.tsx From jmix-frontend with Apache License 2.0 | 5 votes |
componentDidMount(): void {
// When `data` has changed (e.g. due to sorting, filtering or pagination change) some of the selected rows
// may not be displayed anymore and shall be removed from selectedRowKeys
this.disposers.push(reaction(
() => [this.items, this.props.loading],
([items, loading]: any) => { // TODO proper typing
if (this.isRowSelectionEnabled && this.selectedRowKeys.length > 0 && !loading) {
const displayedRowKeys = items.map((item: EntityInstance<TEntity>) => this.constructRowKey(item));
this.selectedRowKeys = this.selectedRowKeys.filter(selectedKey => displayedRowKeys.indexOf(selectedKey) > -1);
}
}, {
equals: comparer.structural
}
));
// Display error message if data retrieval has failed
this.disposers.push(reaction(
() => this.props.error,
(error) => {
const {intl} = this.props;
if (error != null) {
message.error(intl.formatMessage({id: 'common.requestFailed'}));
}
}
));
// Call corresponding callback(s) when selectedRowKeys is changed
this.disposers.push(reaction(
() => this.selectedRowKeys,
this.onRowSelectionChange
));
// Clear row selection when rowSelectionMode is changed
this.disposers.push(reaction(
() => this.props.rowSelectionMode,
() => {
this.selectedRowKeys = [];
}
))
}
Example #3
Source File: KubeForceChart.tsx From lens-resource-map-extension with MIT License | 5 votes |
async componentDidMount() {
this.setState(this.state)
this.kubeObjectStores = [
this.podsStore,
this.deploymentStore,
this.statefulsetStore,
this.daemonsetStore,
this.serviceStore,
this.ingressStore,
this.pvcStore,
this.configMapStore,
this.secretStore,
]
await this.loadData();
this.displayChart();
const fg = this.chartRef.current;
fg.zoom(1.3, 1000);
fg?.d3Force('link').strength(1.3).distance(() => 60)
fg?.d3Force('charge', d33d.forceManyBody().strength(-60).distanceMax(250));
fg?.d3Force('collide', d3.forceCollide(40));
fg?.d3Force("center", d3.forceCenter());
const reactionOpts = {
equals: comparer.structural,
}
disposeOnUnmount(this, [
reaction(() => this.namespaceStore.selectedNamespaces, this.namespaceChanged, reactionOpts),
reaction(() => this.podsStore.items.toJSON(), () => { this.refreshItems(this.podsStore) }, reactionOpts),
reaction(() => this.daemonsetStore.items.toJSON(), () => { this.refreshItems(this.daemonsetStore) }, reactionOpts),
reaction(() => this.statefulsetStore.items.toJSON(), () => { this.refreshItems(this.statefulsetStore) }, reactionOpts),
reaction(() => this.deploymentStore.items.toJSON(), () => { this.refreshItems(this.deploymentStore) }, reactionOpts),
reaction(() => this.serviceStore.items.toJSON(), () => { this.refreshItems(this.serviceStore) }, reactionOpts),
reaction(() => this.secretStore.items.toJSON(), () => { this.refreshItems(this.secretStore) }, reactionOpts),
reaction(() => this.pvcStore.items.toJSON(), () => { this.refreshItems(this.pvcStore) }, reactionOpts),
reaction(() => this.ingressStore.items.toJSON(), () => { this.refreshItems(this.ingressStore) }, reactionOpts),
reaction(() => this.configMapStore.items.toJSON(), () => { this.refreshItems(this.configMapStore) }, reactionOpts)
])
}