Skip to content

Instantly share code, notes, and snippets.

View pglazkov's full-sized avatar

Pavlo Glazkov pglazkov

View GitHub Profile
public abstract class ResourceAccessor : MarkupExtension
{
private static readonly IDictionary<Type, Uri> UriCache = new Dictionary<Type, Uri>();
public Uri Uri
{
get
{
var result = GetUriWithCache();
@pglazkov
pglazkov / AsyncRetry.cs
Last active October 11, 2018 09:23
Asynchronous Retry Helper
public static class AsyncRetry
{
public static async Task DoAsync(Func<Task> action,
AsyncRetryPolicy policy = null,
CancellationToken? cancellationToken = null)
{
await DoAsync(async () =>
{
await action();
return true;
@pglazkov
pglazkov / webpack.config.js
Created October 17, 2017 12:50
Webpack.config.js for multiple applications
const CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const apps = [
{
name: 'app1',
baseUrl: '/app1'
},
{
name: 'app2',
import {
ApplicationRef, ComponentFactoryResolver, ComponentRef,
EmbeddedViewRef, Injectable, Injector, Type, ViewContainerRef
} from '@angular/core';
@Injectable()
export class ComponentFactoryService {
constructor(
private cfr: ComponentFactoryResolver,
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component'
import { DynamicComponent } from './dynamic.component';
import { ComponentFactoryService } from './component-factory.service';
@NgModule({
declarations: [
AppComponent,
import { Component } from '@angular/core';
import { ComponentFactoryService } from './component-factory.service';
import { DynamicComponent } from './dynamic.component';
@Component({
selector: 'app-home',
template: '<div #host></div>'
})
export class HomeComponent {
@ViewChild('host', {read: ViewContainerRef})
import {
ApplicationRef, Componenimport {
ApplicationRef, ComponentFactoryResolver, ComponentRef,
Injectable, Injector, Type, ViewContainerRef
} from '@angular/core';
import {
ComponentType,
Portal,
ComponentPortal,
import { Component } from '@angular/core';
import { SharedData } from '../shared-data';
@Component({
selector: 'app-sidebar',
template: `
Item count: <span>{{ getItemCount() | async }}</span>
`
})
export class SidebarComponent {
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { AsyncSubject } from 'rxjs/AsyncSubject';
export interface DataValue {
items: string[];
}
@Injectable()
export class SharedData {
import { Component } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { SharedData } from '../shared-data';
@Component({
selector: 'app-main',
template: `
<button (click)="loadData()">Load data</button>
<div *ngIf="sharedData.value | async; let data">