You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A flexible, efficient, and lightweight dependency injection library for React applications. Future versions plan to add Vue support. The current version only implements the React part.
3
+
A flexible, efficient, and lightweight dependency injection library for <b>React/Vue3</b> applications.
4
4
5
5
The library is inspired by the principles and architectural approach of NestJS and Angular, but adapted for frontend applications.
<div v-else-if="error">Error is: {{ error }}</div>
228
+
<div v-else-if="user">
229
+
<h2>{{ user.name }}</h2>
230
+
<p>Email: {{ user.email }}</p>
231
+
<button @click="loadUser()">Load user 123</button>
232
+
<button @click="callServiceA()">Call service A</button>
233
+
</div>
234
+
</div>
235
+
</template>
236
+
```
237
+
158
238
## Detailed Guide
159
239
160
240
### Decorators
@@ -381,7 +461,7 @@ FlexDI supports asynchronous initialization and the use of Promises:
381
461
exportclassConfigModule {}
382
462
```
383
463
384
-
## React Integration
464
+
## Integration
385
465
386
466
### ErrorBoundaryView Component
387
467
```tsx
@@ -418,7 +498,7 @@ export class ErrorBoundaryView extends Component<ErrorBoundaryProps, ErrorBounda
418
498
}
419
499
```
420
500
421
-
### RootModuleLoader
501
+
### RootModuleLoader React
422
502
423
503
Component for loading the root module of the application:
424
504
@@ -436,7 +516,32 @@ Component for loading the root module of the application:
436
516
437
517
The `enableStrictMode` parameter should be set to `true` ONLY when `<StrictMode>` is used in the application and you are in development mode. Otherwise, be sure to set it to `false`, otherwise the presenters will not receive ready/destroy events and will not work correctly.
438
518
439
-
### ModuleLoader
519
+
520
+
### RootModuleLoader Vue3
521
+
522
+
Component for loading the root module of the application:
523
+
```vue
524
+
<script setup lang="ts">
525
+
import { RootModuleLoader } from 'flexdi/vue3'
526
+
import ErrorComponent from './common/app-ui/ErrorComponent.vue'
527
+
import LoadingComponent from './common/app-ui/LoadingComponent.vue'
528
+
import { RootModule } from './RootModule.ts'
529
+
530
+
const rootModule = RootModule
531
+
</script>
532
+
533
+
<template>
534
+
<RootModuleLoader
535
+
:module="rootModule"
536
+
:loading-component="LoadingComponent"
537
+
:error-component="ErrorComponent"
538
+
>
539
+
<router-view></router-view>
540
+
</RootModuleLoader>
541
+
</template>
542
+
```
543
+
544
+
### ModuleLoader React
440
545
441
546
Component for loading a module and its dependencies:
442
547
@@ -451,6 +556,30 @@ Component for loading a module and its dependencies:
451
556
</ModuleLoader>
452
557
```
453
558
559
+
### ModuleLoader Vue3
560
+
561
+
Component for loading the root module of the application:
562
+
```vue
563
+
<script setup lang="ts">
564
+
import { ModuleLoader } from 'flexdi/vue3'
565
+
import ErrorComponent from './common/app-ui/ErrorComponent.vue'
566
+
import LoadingComponent from './common/app-ui/LoadingComponent.vue'
567
+
import { FeatureModule } from './FeatureModule.ts'
568
+
569
+
const featureModule = FeatureModule
570
+
</script>
571
+
572
+
<template>
573
+
<ModuleLoader
574
+
:module="featureModule"
575
+
:loading-component="LoadingComponent"
576
+
:error-component="ErrorComponent"
577
+
>
578
+
<router-view></router-view>
579
+
</ModuleLoader>
580
+
</template>
581
+
```
582
+
454
583
### useInject
455
584
456
585
Hook for injecting dependencies into functional components:
@@ -476,7 +605,7 @@ Hook for subscribing to Observable with automatic unsubscription:
0 commit comments