zalmoxisus / mobx-remotedev

MobX DevTools extension
MIT License
328 stars 40 forks source link

Use with Angular 2 #16

Closed Jonatthu closed 7 years ago

Jonatthu commented 7 years ago

I'm using https://github.com/500tech/ng2-mobx How can I use this with angular 2? Some code snippet please?

zalmoxisus commented 7 years ago

Unfortunately, I'm not familiar with Angular. I guess you are not allowed to have access to window object directly there. What's the error you get? I guess we should provide a helper like for redux. Maybe someone could step out and implement that here.

Jonatthu commented 7 years ago

The solution it's super simple thanks to this package I'm working now with devtools

Just install the npm package and use it in the store like this in angular 2, that should work!

import remotedev from 'mobx-remotedev/lib/dev';

@Injectable()
@remotedev({ name: 'Todo list', global: true })
export class EBandStore {
adamkleingit commented 7 years ago

You should be able to use it without the @Injectable decorator (as long as there is any kind of decorator Angular can use DI on it)

creaux commented 6 years ago

@adamkleingit for me dependency injection doesn't work without @Injectable. And in tandem with @remotedev neither so. There seems to be really no way how to use @remotedev as decorator on service?