X
X
X0lera2019-02-19 10:07:22
Angular
X0lera, 2019-02-19 10:07:22

Rate the app?

Help evaluate the application and poke where you can do better
https://github.com/BuG1K/task/tree/master/src/app

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Luzanov, 2019-02-19
@X0lera

It is better to specify the type not through the primitive constructor, but through the string type (the one from TypeScript, with a small letter). You are not using RxJS features. This piece of code can be done differently:

ngOnInit() {
    this.Preview.url
      .subscribe(new_url => this.url = new_url);
  }

The subscriber will not be destroyed when the component OnDestroy, but will listen to a new url until it is unloaded from memory by the garbage collector. It would be better to do it like this:
public previewUrl$: Observable<string>

ngOnInit() {
    this.previewUrl$ = this.Preview.url
}

<div class="preview" *ngIf="(previewUrl$ | async) as url">
  <img class="preview__img" [src]="url">
</div>

In the service as well ( https://github.com/BuG1K/task/blob/master/src/app/... you subscribed to the http request and do not use RxJS any more. All manipulations could be done in tap / map and return stream that is easy to work with.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question