-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve perf and avoid updating data or view when not necessary (…
…#58) * feat: optimize view recreation * feat: improve perf and avoid updating data or view when not necessary * feat: save little more computation
- Loading branch information
Showing
6 changed files
with
79 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// eslint-disable-next-line import/prefer-default-export | ||
export const NOOP = () => {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Result } from 'vega-embed'; | ||
|
||
export type View = Result['view']; | ||
|
||
export type PlainObject = { | ||
[key: string]: any; | ||
}; | ||
|
||
export type SignalListener = (name: string, value: any) => void; | ||
|
||
export type SignalListeners = { | ||
[key: string]: SignalListener; | ||
}; | ||
|
||
export type ViewListener = (view: View) => void; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { PlainObject } from '../types'; | ||
|
||
export default function getUniqueFieldNames(objects: PlainObject[]) { | ||
const fields = new Set(); | ||
objects.forEach(o => { | ||
Object.keys(o).forEach(field => { | ||
fields.add(field); | ||
}); | ||
}); | ||
|
||
return fields; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { PlainObject } from '../types'; | ||
|
||
const EMPTY = {}; | ||
|
||
export default function shallowEqual(a: PlainObject = EMPTY, b: PlainObject = EMPTY) { | ||
const aKeys = Object.keys(a); | ||
const bKeys = Object.keys(b); | ||
|
||
return a === b || (aKeys.length === bKeys.length && aKeys.every(key => a[key] === b[key])); | ||
} |