Skip to content

Instantly share code, notes, and snippets.

View kagklis's full-sized avatar
🏠
Working from home

Vasileios Kagklis kagklis

🏠
Working from home
View GitHub Profile
public class Person {
/** The first name. */
private String firstName;
/** The last name. */
private String lastName;
/**
* Returns the full name of the person.
public dropped(event: CdkDragDrop<Item[], Item[], Item>) {
// VirtualScrolling and CdkDropList don’t work well together.
// Workaround solution: set the correct previousIndex manually.
event.previousIndex = event.previousContainer.data.findIndex(
(item) => item.id === event.item.data.id
);
// ...
}
// TODO: Revert temporary changes (special handle of bugged type)
// when backend issue is resolved.
public onSelection(selected: SomeObjectWithType): void {
if (selected.type === ObjectType.TypeWithBug)) {
// handles buggy case separately
} else {
// original behavior
}
}
// Check if our hero can defeat the villain
if (hero.strength > villain.strength &&
hero.energy > 30 &&
!villain.bersekerMode) {
// ...
}
if (hero.canDefeat(villain)) {
// ...
}
// Don't run unless you got more than 10 GB of RAM free.
// Alternatively, decrease the value of N.
public void _testWithLargeN() {
// ...
}
<cdk-virtual-scroll-viewport
*ngIf="items?.length"
class="selection-list col-lg-7"
[itemSize]="74"
>
<div
class="item"
[ngClass]="{ selected: selectedItems[item.id] }"
*cdkVirtualFor="let item of items"
(click)="selectItem(item)"
<app-selection-list
[items]="pandas$ | async"
(selectionChanged)="updateSelection($event)"
>
<ng-template #itemTemplate let-item>
<app-panda [panda]="item"></app-panda>
</ng-template>
</app-selection-list>
<app-selection-list
[items]="movies$ | async"
(selectionChanged)="updateSelection($event)"
>
<ng-template #itemTemplate let-item>
<app-movie [movie]="item"></app-movie>
</ng-template>
</app-selection-list>
@Component({
selector: 'app-selection-list',
templateUrl: './selection-list.component.html',
styleUrls: ['./selection-list.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class SelectionListComponent {
public selectedItems: SelectedItems = {};
@Input() items!: IdOwner[] | null;