Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/core/plugins/view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,22 @@ import { memoize } from "core/utils"

import { getComponent, render, withMappedContainer } from "./root-injects"
import { getDisplayName } from "./fn"
import memoizeN from "../../../helpers/memoizeN"

const memoizeForGetComponent = (fn) => {
const resolver = (...args) => JSON.stringify(args)
return memoize(fn, resolver)
}

const memoizeForWithMappedContainer = (fn) => {
const resolver = (...args) => args
return memoizeN(fn, resolver)
}

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

return {
rootInjects: {
Expand Down