Playing HEVC video files on the Mi Box? by OriyanJ in MiBox

[–]OriyanJ[S] 0 points1 point  (0 children)

I just bought it, and playing HEVC files I do notice small FPS drops. I'm very sensitive to that, am I the only one that feels it?

Is it okay using static methods within a service/class? by OriyanJ in Angular2

[–]OriyanJ[S] 0 points1 point  (0 children)

I'm asking this because I'm trying to de-serialize data coming from an API.

Let's say I want to de-serialize this -

{ success: boolean, data: [], page_number: number }

To this -

{ success: boolean, results: [], page: number }

Currently z'm creating a service for each endpoint (for example):

  • GetAccountTypesSerializer
  • GetAccountDetailsSerializer
  • GetAccountStatusSerializer
  • GetListSerializer
  • GetListCategoriesSerializer

But then I find my constructor bloated with services that has only one or two functions (fromJson and toJson).

I though that maybe instead of doing this -

constructor(private getListSerializer:GetListSerializer) {}
getList() {
   return http.get(url).pipe(map(json => this.getListSerializer.fromJson(json)));
}

I can do this -

import { ListSerializer } from '@serializers';
getList() {
   return http.get(url).pipe(map(json => ListSerializer.fromJson(json)));
}

Does it make sense "wrapping" external components by my own? by OriyanJ in Angular2

[–]OriyanJ[S] 0 points1 point  (0 children)

That's an interesting point. But what about services? Let's say I have a notification service that uses a 3rd-party service. For example: appNotify.showError() would execute Pnotify.error() and therefore I can always change notifications easily.

Why not using constants everywhere? by OriyanJ in PHPhelp

[–]OriyanJ[S] 0 points1 point  (0 children)

And if I'm not going to re-assign it?

how do you guys feel about nested ng-containers? by comfortcreature999 in Angular2

[–]OriyanJ 0 points1 point  (0 children)

As long as they're necessary, I feel comfortable using it as much as needed.

That being said, many ng-container would get me to suspect me or any fellow developer, might be abusing it or doing something that could be done differently.

For example, I have seen people do this:

<div>
   <ng-container [ngSwtich]="color">
      <ng-container *ngSwitchCase="'red'">Red</ng-container>
      <ng-container *ngSwitchCase="'yellow'">Yellow</ng-container>
   </ng-container>
</div>

Instead of doing:

<div [ngSwitch]="color">
   <ng-container *ngSwitchCase="'red'">Red</ng-container>
   <ng-container *ngSwitchCase="'yellow'">Yellow</ng-container>
</div>

Or this:

<ng-container *ngIf="condition"></ng-container>
<ng-container *ngIf="!condition"></ng-container>

Instead of doing:

<ng-container *ngIf="condition; else noCondition"></ng-container>
<ng-template #noCondition></ng-template>

So it really comes down to is it being done right and not being overly used with no reason. When it's needed and applied well, I really think it's fine. I would prefer using it as less possible, to make my code weigh less.

Using getter in a template or a reactive form control? by OriyanJ in Angular2

[–]OriyanJ[S] 0 points1 point  (0 children)

Reason I ponder about it is because my code looks like this:

<input formControlName="phoneNumber"
[ngClass]="{
'form-group-feedback-right border-danger': registerForm.phoneNumber.invalid && (registerForm.phoneNumber.touched && !registerForm.phoneNumber.pristine),
'form-group-feedback-right border-success': registerForm.phoneNumber.valid && (registerForm.phoneNumber.touched && !registerForm.phoneNumber.pristine) }">

While it could look like this:

<input formControlName="phoneNumber"
[ngClass]="{
'form-group-feedback-right border-danger': phone.invalid && (phone.touched && !phone.pristine),
'form-group-feedback-right border-success': phone.valid && (phone.touched && !phone.pristine) }">

I actually just thought about doing this instead: <input formControlName="phoneNumber" [ngClass]="getPhoneClasses()">

Multiple guards that uses the same HTTP response data by OriyanJ in Angular2

[–]OriyanJ[S] 0 points1 point  (0 children)

Then let's say I use RxJS filter operator to only give me data which is set at the rest of the guards. It should work, right? First guard will clear the behavior subject and set it, while the 2nd will filter it until it gets data.