Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ea.payload.entityOp.endsWith(OP_ERROR)
)
)
// this service never dies so no need to unsubscribe
.subscribe(action =>
toast.openSnackBar(
`${action.payload.entityName} action`,
action.payload.entityOp
)
);
actions$
.pipe(
ofType(
EntityCacheAction.SAVE_ENTITIES_SUCCESS,
EntityCacheAction.SAVE_ENTITIES_ERROR
)
)
.subscribe((action: any) =>
toast.openSnackBar(
`${action.type} - url: ${action.payload.url}`,
'SaveEntities'
)
);
}
}
ea.payload.entityOp.endsWith(OP_SUCCESS) ||
ea.payload.entityOp.endsWith(OP_ERROR)
)
)
// this service never dies so no need to unsubscribe
.subscribe(action =>
toast.openSnackBar(
`${action.payload.entityName} action`,
action.payload.entityOp
)
);
actions$
.pipe(
ofType(
EntityCacheAction.SAVE_ENTITIES_SUCCESS,
EntityCacheAction.SAVE_ENTITIES_ERROR
)
)
.subscribe((action: any) =>
toast.openSnackBar(
`${action.type} - url: ${action.payload.url}`,
'SaveEntities'
)
);
}
}
constructor(actions$: Actions, toast: ToastService) {
actions$
.pipe(
ofEntityOp(),
filter(
(ea: EntityAction) =>
ea.payload.entityOp.endsWith(OP_SUCCESS) ||
ea.payload.entityOp.endsWith(OP_ERROR)
)
)
// this service never dies so no need to unsubscribe
.subscribe(action =>
toast.openSnackBar(
`${action.payload.entityName} action`,
action.payload.entityOp
)
);
actions$
.pipe(
}
if (
ts.isVariableDeclaration(node) &&
node.type &&
renameKeys.includes(node.type.getText(sourceFile))
) {
change = {
node: node.type,
text: node.type.getText(sourceFile),
};
}
if (change) {
changes.push(
createReplaceChange(
sourceFile,
change.node,
change.text,
(renames as any)[change.text]
)
);
}
ts.forEachChild(node, childNode => find(childNode, changes));
}
}
.map(({ specifier, text }) =>
createReplaceChange(
sourceFile,
specifier!,
text!,
(renames as any)[text!]
)
);
const changes = imports.map(specifier =>
createReplaceChange(
sourceFile,
specifier.moduleSpecifier,
"'ngrx-data'",
"'@ngrx/data'"
)
);
const apiRoot = environment.apiUrlBase + '/';
const defaultDataServiceConfig: DefaultDataServiceConfig = {
root: apiRoot,
entityHttpResourceUrls: {
Customer: { entityResourceUrl: apiRoot + 'customers/', collectionResourceUrl: apiRoot + 'customers/' },
Order: { entityResourceUrl: apiRoot + 'orders/', collectionResourceUrl: apiRoot + 'orders/' },
}
};
@NgModule({
imports: [
StoreModule.forRoot({}),
EffectsModule.forRoot([]),
EntityDataModule.forRoot(),
environment.production ? [] : StoreDevtoolsModule.instrument()
],
providers: [ { provide: DefaultDataServiceConfig, useValue: defaultDataServiceConfig } ]
})
export class AppStoreModule {}
import { entityConfig } from './entity-metadata';
const apiRoot = environment.apiUrlBase + '/';
const defaultDataServiceConfig: DefaultDataServiceConfig = {
root: apiRoot,
entityHttpResourceUrls: {
Customer: { entityResourceUrl: apiRoot + 'customers/', collectionResourceUrl: apiRoot + 'customers/' },
Order: { entityResourceUrl: apiRoot + 'orders/', collectionResourceUrl: apiRoot + 'orders/' },
}
};
@NgModule({
imports: [
StoreModule.forRoot({}),
EffectsModule.forRoot([]),
EntityDataModule.forRoot(entityConfig),
environment.production ? [] : StoreDevtoolsModule.instrument()
],
providers: [ { provide: DefaultDataServiceConfig, useValue: defaultDataServiceConfig } ]
})
export class AppStoreModule {}
import { EffectsModule } from '@ngrx/effects';
import { StoreModule } from '@ngrx/store';
import { StoreDevtoolsModule } from '@ngrx/store-devtools';
import { environment } from '../../environments/environment';
import { entityConfig } from './entity-metadata';
import { EntityDataModule } from '@ngrx/data';
import { NgrxDataToastService } from './ngrx-data-toast.service';
import { VillainEffects } from './villains/villain-effects';
@NgModule({
imports: [
StoreModule.forRoot({}),
EffectsModule.forRoot([VillainEffects]),
environment.production ? [] : StoreDevtoolsModule.instrument(),
EntityDataModule.forRoot(entityConfig)
]
})
export class AppStoreModule {
constructor(toastService: NgrxDataToastService) {}
}
const modulePath = options.module!;
const text = host.read(modulePath)!.toString();
const source = ts.createSourceFile(
modulePath,
text,
ts.ScriptTarget.Latest,
true
);
const moduleToImport = options.effects
? 'EntityDataModule'
: 'EntityDataModuleWithoutEffects';
const effectsModuleImport = insertImport(
source,
modulePath,
moduleToImport,
'@ngrx/data'
);
const [dateEntityNgModuleImport] = addImportToModule(
source,
modulePath,
options.entityConfig
? [moduleToImport, 'forRoot(entityConfig)'].join('.')
: moduleToImport,
''
);
const changes = [effectsModuleImport, dateEntityNgModuleImport];