letoast
letoast
Explore posts from servers
NNuxt
Created by letoast on 4/17/2024 in #❓・help
Adding to composable using a Layer
yeah, the idea is to keep the naming of composables the same so that another layer just overrides/adds on top and there's no need to change anything in the consumer's code
32 replies
NNuxt
Created by letoast on 4/17/2024 in #❓・help
Adding to composable using a Layer
yes layer B is extending layer A
32 replies
NNuxt
Created by letoast on 4/17/2024 in #❓・help
Adding to composable using a Layer
meaning if you have a page/component/layout using useSomeComposable you have to replace it with the one that overrides it everywhere
32 replies
NNuxt
Created by letoast on 4/17/2024 in #❓・help
Adding to composable using a Layer
hmmm but then they're not switchable
32 replies
NNuxt
Created by letoast on 4/17/2024 in #❓・help
Adding to composable using a Layer
there's also one more problem i noticed. if there's a composable useX.ts in layer A that's defined as
// layerA/composables/useX.ts
import { get } from './x/get.ts'
...
// layerA/composables/useX.ts
import { get } from './x/get.ts'
...
and we override get.ts in layer B
// layerB/composables/x/get.ts
...
// layerB/composables/x/get.ts
...
layer B's get.ts doesn't override layer A's get.ts - it doesn't seem to include them
32 replies
NNuxt
Created by letoast on 4/17/2024 in #❓・help
Adding to composable using a Layer
as in "each function in composables named XYZ should have this type"
32 replies
NNuxt
Created by letoast on 4/17/2024 in #❓・help
Adding to composable using a Layer
hmm do you see any way of enforcing a type on a composable with the same name as the composable in the base layer without having to import the type manually?
32 replies
NNuxt
Created by letoast on 4/17/2024 in #❓・help
Adding to composable using a Layer
and the layer's author might forget to import some methods that should be there by default
32 replies
NNuxt
Created by letoast on 4/17/2024 in #❓・help
Adding to composable using a Layer
the problem i have with this is that the composable has to be defined then in each layer
32 replies
NNuxt
Created by letoast on 4/17/2024 in #❓・help
Adding to composable using a Layer
but i was thinking if there's a better way than that
32 replies
NNuxt
Created by letoast on 4/17/2024 in #❓・help
Adding to composable using a Layer
so then the next layer can override each
32 replies
NNuxt
Created by letoast on 4/17/2024 in #❓・help
Adding to composable using a Layer
another way i could do this is just splitting each method inside the composable into it's own composable usePost useGet useDelete etc
32 replies
NNuxt
Created by letoast on 4/17/2024 in #❓・help
Adding to composable using a Layer
so much so that you don't want to cover 10 different cases in the base layer if you have 10 tenants
32 replies
NNuxt
Created by letoast on 4/17/2024 in #❓・help
Adding to composable using a Layer
transforming the request in a different way, calling another endpoint in the same function, can be whatever
32 replies
NNuxt
Created by letoast on 4/17/2024 in #❓・help
Adding to composable using a Layer
let's say layer/tenant2 needs to implement the delete property inside the composable in a different way than the base layer has it implemented, how would you do that?
32 replies
NNuxt
Created by letoast on 4/17/2024 in #❓・help
Adding to composable using a Layer
how do you mean a configurable composable?
32 replies
NNuxt
Created by letoast on 4/17/2024 in #❓・help
Adding to composable using a Layer
The reason is that there would be multiple layers that would add different functionalities depending on the layer's needs, but the core functionality should be there. I don't want to duplicate the core functionality to each layer. I'll give you an example layers/tenant1/ layers/tenant2/ layers/tenant3/ layers/base/ ... where the app is basically made to be multi tenant/version. There are different developers working on this and I would like to force this composable to have a certain basic structure. I know I could create a type definition for the composable and extend it in each layer, but is there any way to force the composable to have a type in each layer without importing the type each time? The only way I see this being possible now is splitting the composable to multiple composables or the type way which I wrote above.
32 replies