This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
// This widget is the root of your application. | |
@override | |
Widget build(BuildContext context) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function* splitArrayToChunks<T>(array: Array<T>, chunkSize: number = Infinity): IterableIterator<Array<T>> { | |
let resultTasks: Array<T> = []; | |
for (let i = 0; i < array.length; i += 1) { | |
const item = array[i]; | |
resultTasks.push(item); | |
// На последнем элементе если не сделать return - | |
// генератор завершится только на следующем шаге с пустым массивом | |
if (i === array.length - 1) { | |
return resultTasks; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useEffect, useState } from 'react'; | |
import { Observable } from 'rxjs'; | |
import { distinctUntilChanged } from 'rxjs/operators'; | |
export type RxBindProps<T> = { | |
stream: Observable<T>; | |
children(dataFromStream: T | void): JSX.Element | Array<JSX.Element> | null; | |
}; | |
export function RxBind<T>(props: RxBindProps<T>): JSX.Element { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useState } from 'react'; | |
import { Observable } from 'rxjs'; | |
import { distinctUntilChanged } from 'rxjs/operators'; | |
/** | |
* Компонент-аналог *ngIf - принимает на вход поток Observable<boolean>. Если в поток приходит true - рисует содержимое | |
*/ | |
export function RxIf(props: { conditionStream: Observable<boolean>, children: JSX.Element }): JSX.Element { | |
// @ts-ignore | |
const [state, setState] = useState({ active: false }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MetaValidationProxy { | |
validity$: BehaviorSubject; | |
attachSource(): void { | |
// Тут все начальные данные перекинутся в прокси и создастся привязка для проброса данных | |
} | |
} | |
// Класс, в котором без декораторов задаются параметры для валидаций | |
@Proxy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type MethodDecorator = (target: any, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor) => | |
TypedPropertyDescriptor | void; | |
type AssertFn = (...args: Array<any>) => void; | |
class TSContract { | |
private static isCustomContractInterruptionCb: boolean = false; | |
private static contractInterruptionCb(message: string): void { | |
console.warn(message); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type PropertyDecorator = (target: any, propertyKey: string | symbol) => void; | |
type MethodDecorator = (target: any, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor) => | |
TypedPropertyDescriptor | void; | |
type ClassDecorator = (target: any) => any; | |
function ClassDecoratorImpl(...decoratorArgs: Array<any>): ClassDecorator { | |
console.log('injectable works fine'); | |
return function(target) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const protoStore = new WeakMap(); | |
function protoKeys(target) { | |
let retKeys = []; | |
while(target.__proto__) { | |
const pKeys = protoStore.get(target.__proto__); | |
if (pKeys) { | |
retKeys = [...retKeys, ...protoStore.get(target.__proto__)]; | |
} | |
target = target.__proto__; |