Akita: AkitaNgDevtools (.forFeature ?) to work with lazy loaded modules

Created on 30 Oct 2018  路  9Comments  路  Source: datorama/akita

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[x ] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behaviour


AkitaNgDevtools isn't working when it's being imported to a module which is lazy loaded (unlike StoreDevtoolsModule of ngrx for example).

Expected behaviour


For AkitaNgDevtools to work with a lazy loaded module.
Something like AkitaNgDevtools.forFeature().

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?


Although it seems unlikely, sometimes we want an app which only part of it will implement Akita.

Environment


Angular version: 7.1.0 beta


Browser:
- [x ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX

For Tooling issues:
- Node version: XX  
- Platform:  

Others:

help wanted

Most helpful comment

You can't use the AkitaNgDevtools.forRoot() module as it relies on the application bootstrap process. But it works with the underline API.

import { akitaDevtools } from '@datorama/akita';

akitaDevtools(); <======

const routes: Routes = [
  { path: '', component: LazyLoadedComponent }];

@NgModule({
  imports: [
    CommonModule,
    RouterModule.forChild(routes)
  ],
  providers: [ExampleQuery, ExampleStore, ExampleService],
  declarations: [LazyLoadedComponent],
})
export class LazyLoadedModule { }

All 9 comments

I'm not sure what you mean as Akita dev-tools works with lazily loaded modules. What is the problem?

@NataneBasal
Oh, well I either implemented it in a wrong way or its a bug.
When I try to import Akita dev-tool to the lazy loaded module, its simply not working.
But when I import it to AppModule its work perfectly.

Can you create a simple demo on stackblitz or upload a simple demo to GitHub, please?

Can you create a simple demo on stackblitz or upload a simple demo to GitHub, please?

https://stackblitz.com/edit/angular-pvyj9v

  1. Devtool is imported to lazy loaded module with no result in the redux extension
  2. Comment it out and go to app module. uncomment the akita devtool and see the result in the redux extension.

*might need to hard reload between changes.

Why do you need to inject it in a lazy load module?

This part of our app needs to be lazy loaded and this is the only part (for now) which implements Akita.
I understand this is a very unusual scenario but this is due to the nature of this app being used for training and experiment purposes.

I will try to investigate, but can't promise anything :)

That's fine, we still love Akita and looking forward to use it more extensively in the future!

You can't use the AkitaNgDevtools.forRoot() module as it relies on the application bootstrap process. But it works with the underline API.

import { akitaDevtools } from '@datorama/akita';

akitaDevtools(); <======

const routes: Routes = [
  { path: '', component: LazyLoadedComponent }];

@NgModule({
  imports: [
    CommonModule,
    RouterModule.forChild(routes)
  ],
  providers: [ExampleQuery, ExampleStore, ExampleService],
  declarations: [LazyLoadedComponent],
})
export class LazyLoadedModule { }
Was this page helpful?
0 / 5 - 0 ratings

Related issues

johanrin picture johanrin  路  7Comments

stherrienaspnet picture stherrienaspnet  路  3Comments

brgrz picture brgrz  路  4Comments

amr-alamir picture amr-alamir  路  6Comments

hoisel picture hoisel  路  5Comments