- Заглушка при первой загрузке. Любой компонент в момент загрузки показывает опционально настраиваемую дефолтную заглушку.
- Автоматическая плавность перехода между перезагрузками компонента. Без isPending и подобных проверок в прикладном коде. Если первый раз уже грузили состояние, то последующая загрузка должна приводить к лёгкому приглушению и переключению на новый текст, вместо переключения на заглушку и переключению на новый текст
- Абстракция от асинхронности в прикладном коде. Не нужны эффекты с fetch, async/await, не нужно поднимать дозагрузку деталей стейта в угоду технической реализации работы с асинхронностью
- Ленивость из коробки, как, например, computed в mobx вычислится только в момент доступа к нему (что если поместить fetch в computed).
- Автоматизация саспенс-кэша, когда закэшированные данные, полученные через fetch и React.Suspense, очищаются при отмонтировании компонента, экономя память и уменьшая вероятность
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
namespace $ { | |
const rec = $mol_data_record | |
const cnst = $mol_data_const | |
const str = $mol_data_string | |
const bool = $mol_data_boolean | |
const opt = $mol_data_optional | |
const nul = $mol_data_nullable | |
export const $gd_kit_object_ws_ins_data = rec({ | |
...$gd_kit_prop_data.config, |
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
namespace $ { | |
const status_key = Symbol('$gd_kit_entity.status') | |
export class $gd_kit_entity extends $mol_object { | |
constructor(id?: string) { | |
super() | |
if (id) this.id = $mol_const(id) | |
} | |
// p-ка свойства-объекта | |
@ $mol_mem |
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
namespace $ { | |
const cache = new WeakMap<Object, Map<PropertyKey, Function>>() | |
function $gd_rad_error_safe_prop<Host, Args extends unknown[]>( this: Host, val: (this: Host, ...args: Args) => unknown, ...args: Args ) { | |
try { | |
let result = val.call(this, ...args) | |
if ($mol_promise_like(result)) { | |
result = result.catch( | |
err => err instanceof Error ? |
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
namespace $ { | |
type Unit<Full, Patch> = ReturnType<typeof $mol_promise<Full | null>> & { | |
id: string | |
patch?: Patch | null | |
} | |
export class $gd_kit_batch< | |
Full extends {}, | |
Patch extends ({} | null) = Partial<Full>, | |
> extends $mol_object { |
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
/** | |
return $gd_rad_transport_query.make({ | |
query: $mol_const(query), | |
assert: $mol_data_string, | |
}) | |
*/ | |
class $gd_rad_transport_query<Item> extends $mol_object { | |
query() { | |
return '' | |
} |
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
namespace $ { | |
export class $gd_rad_session_web extends $gd_rad_session { | |
client_id() { | |
return 'pa-admin' | |
} | |
@ $mol_mem | |
token_access(next?: string | null) { | |
return this.$.$gd_rad_transport.token(next) ?? undefined | |
} |
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
declare class AggregateError extends Error { | |
readonly errors: (Error | object | string)[]; | |
constructor(errors: readonly (Error | object | string)[], message: string, options?: { cause: unknown }); | |
} | |
function createAggregateErrorStub(): typeof AggregateError { | |
return class AggregateErrorStub extends Error { | |
constructor(readonly errors: (Error | object | string)[], message: string, options?: { cause: unknown }) { | |
// @ts-ignore | |
super(message, options); |
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 ErrorObjectBase = { __typename: string | undefined; message?: string; path?: readonly string[] } | |
export type GqlApiServiceErrorDto = { | |
__typename: undefined; | |
locations?: readonly { line: number; column: number }[]; | |
message?: string; | |
path?: readonly string[]; | |
} | |
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
namespace $ { | |
type Unit<Full, Patch> = $mol_promise<Full | null> & { | |
id: string | |
patch?: Patch | null | |
error: Error | |
} | |
export class $gd_kit_batch< | |
Full extends {}, | |
Patch extends ({} | null) = Partial<Full>, |