open-index/open-npm huggingface dataset:
npm package: @ngx-electron/electron-data-shared
Description: Rely on angular 6.x.x and electron 2.x.x and @ng/store 6.x.x and @ngx-electron/electron-core
Latest version: 0.0.1
Deprecated: this package has been deprecated, use @ngx-electron/data instead

# @ngx-electron/electron-data-shared

Rely on angular 6.x.x and electron 2.x.x and @ng/store 6.x.x and @ngx-electron/electron-core

Use NgxElectronDataSharedService services to synchronize data in multiple windows (data is managed uniformly by store).


## Installation

```
   npm install @ngx-electron/electron-data-shared --save
```

## Usage

```typescript
import {ElectronDataSharedModule} from '@ngx-electron/electron-data-shared'
import {StoreModule} from '@ngrx/store';
import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core';

const reducers = [];
@NgModule({
    declarations: [
        
    ],
    imports: [
        BrowserModule,
        ElectronDataSharedModule,
        StoreModule.forRoot(reducers),
    ],
    providers: [],
    bootstrap: []
})
export class AppModule {
}
```
#### Open a page and synchronize the data

The current page

use NgxElectronDataSharedService openPage
```
openPage({
    url, 
    channel = url, 
    webInvoker
}: {
    url: string, 
    channel?: string, 
    webInvoker?: (string) => void
}, observables?: Observable<Action>[], complete?: () => void)

```

```
// data (action)
const loadUserAction$ = this.store$.pipe(
    select(getUsers),
    map(users => new LoadUserAction(users)),
    take(1)
);
electronDataSharedService.openPage({
    url: 'home/chat-list'
}, [loadUserAction$], () => alert('data send over')));
```

new page
use NgxElectronDataSharedService initStore

```

construct(private electronDataSharedService: NgxElectronDataSharedService) {
}
onInit() {
    electronDataSharedService.initStore();
}
```

#### Multiple pages pass the data(action, eg: LoadUserSuccessAction)

On a page use NgxElectronStoreService
```
electronStoreService.dispath({
    type: '[user] init user',
    payload: [user1, user2]
});
```

Other page usage

use initStore() or use onStore()