Skip to content

Commit d638e58

Browse files
authored
fix(view-plugin): provide resolvers for memoized functions (#7801)
Before this change, memoization happened only on first argument provided to the functions. Now the memoization properly handle all arguments. Refs #7800
1 parent 87ccc24 commit d638e58

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/core/plugins/view/index.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,22 @@ import { memoize } from "core/utils"
22

33
import { getComponent, render, withMappedContainer } from "./root-injects"
44
import { getDisplayName } from "./fn"
5+
import memoizeN from "../../../helpers/memoizeN"
6+
7+
const memoizeForGetComponent = (fn) => {
8+
const resolver = (...args) => JSON.stringify(args)
9+
return memoize(fn, resolver)
10+
}
11+
12+
const memoizeForWithMappedContainer = (fn) => {
13+
const resolver = (...args) => args
14+
return memoizeN(fn, resolver)
15+
}
516

617
const viewPlugin = ({getComponents, getStore, getSystem}) => {
718
// getComponent should be passed into makeMappedContainer, _already_ memoized... otherwise we have a big performance hit ( think, really big )
8-
const memGetComponent = memoize(getComponent(getSystem, getStore, getComponents))
9-
const memMakeMappedContainer = memoize(withMappedContainer(getSystem, getStore, memGetComponent))
19+
const memGetComponent = memoizeForGetComponent(getComponent(getSystem, getStore, getComponents))
20+
const memMakeMappedContainer = memoizeForWithMappedContainer(withMappedContainer(getSystem, getStore, memGetComponent))
1021

1122
return {
1223
rootInjects: {

0 commit comments

Comments
 (0)