Skip to content

Commit 0838c4b

Browse files
committed
feat: add composable cache
1 parent 83fe374 commit 0838c4b

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/cache.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/createComposable.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ import type {
4848
} from './types'
4949
import { resolveInjections } from './inject'
5050

51+
export const cache = new Map<any, any>() // TODO: properly type this
52+
5153
export /* @__PURE__ */ function createComposableFromMixin<
5254
Props extends Readonly<ExtractPropTypes<PropsOptions>> & EmitsToProps<E>,
5355
VM extends CreateComponentPublicInstance<
@@ -118,6 +120,10 @@ export /* @__PURE__ */ function createComposableFromMixin<
118120
// mixins,
119121
} = mixin
120122

123+
if (cache.has(mixin)) {
124+
return cache.get(mixin) as any
125+
}
126+
121127
const composable = () => {
122128
const instance = getCurrentInstance()!
123129
const vm = instance.proxy! as VM
@@ -219,6 +225,8 @@ export /* @__PURE__ */ function createComposableFromMixin<
219225
props,
220226
emits,
221227
})
228+
229+
cache.set(mixin, composable)
222230
return composable as typeof composable & { props: PropsOptions; emits: E }
223231
}
224232

0 commit comments

Comments
 (0)