mirror of
https://github.com/gregberge/loadable-components.git
synced 2026-01-18 15:12:26 +00:00
This issue fixes #59 It is possible to create a configuration which will result into a wrong state but it should not happen in 99.99% cases.
18 lines
396 B
JavaScript
18 lines
396 B
JavaScript
let components = {}
|
|
|
|
export const track = (component, modules, index = 0) => {
|
|
let id = modules.join('-')
|
|
if (index) id += `-${index}`
|
|
if (components[id]) {
|
|
return track(component, modules, index + 1)
|
|
}
|
|
components[id] = component
|
|
return id
|
|
}
|
|
|
|
export const get = id => components[id]
|
|
export const getAll = () => ({ ...components })
|
|
export const reset = () => {
|
|
components = {}
|
|
}
|