Is there a way to use generics with `MakeLogicType` ?
JasonStoltz opened this issue · comments
Jason Stoltzfus commented
Something like:
type SomeLogicType<ItemType> = MakeLogicType<
SomeLogicValues<ItemType>,
SomeLogicActions<ItemType>
>;
export const SomeLogic = kea<SomeLogicType<ItemType>>({
Where ItemType
is passed as a type parameter to useValues
or something?
useValues<MyType>(SomeLogic)
Jason Stoltzfus commented
I just wrapped it in a factory function and 👌
export const getSomeLogic = <T>() => {
return kea<SomeLogicType<T>>({
const logic = getSomeLogic<Foo>()();
Marius Andra commented
Jason Stoltzfus commented
That does work. Sorry, to clarify, instead of a concrete type like ItemType
in your example, I want it to be generic. So that the logic can work with any type. So one place where the logic is used it might work with strings, other places might work with numbers, etc.