Skip to content

Instantly share code, notes, and snippets.

@Razzwan
Last active March 9, 2018 12:58
Show Gist options
  • Save Razzwan/3f4ea9113b254837761f68c884007118 to your computer and use it in GitHub Desktop.
Save Razzwan/3f4ea9113b254837761f68c884007118 to your computer and use it in GitHub Desktop.
// One more service, which do nothisn except create new instance with userId field
class oneSignalService {
async create(user, data) {
return this.repository.create<UserOneSignal>({
userId: user.id,
...data,
});
}
}
@Component()
export class MeService {
constructor(
// must be injected one more service here,
private readonly oneSignalService: OneSignalService,
) {}
async someMethod(user, data) {
// We should ignore the availability of the ready-made method within the library used, but use your exact same method
await this.oneSignalService.create<UserOneSignal>(user, data);
}
async reusageInSecondPlace(user, data) {
// We should ignore the availability of the ready-made method within the library used, but use your exact same method
await this.oneSignalService.create<UserOneSignal>(user, data);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment