- Заглушка при первой загрузке. Любой компонент в момент загрузки показывает опционально настраиваемую дефолтную заглушку.
- Автоматическая плавность перехода между перезагрузками компонента. Без isPending и подобных проверок в прикладном коде. Если первый раз уже грузили состояние, то последующая загрузка должна приводить к лёгкому приглушению и переключению на новый текст, вместо переключения на заглушку и переключению на новый текст
- Абстракция от асинхронности в прикладном коде. Не нужны эффекты с fetch, async/await, не нужно поднимать дозагрузку деталей стейта в угоду технической реализации работы с асинхронностью
- Ленивость из коробки, как, например, computed в mobx вычислится только в момент доступа к нему (что если поместить fetch в computed).
- Автоматизация саспенс-кэша, когда закэшированные данные, полученные через fetch и React.Suspense, очищаются при отмонтировании компонента, экономя память и уменьшая вероятность
This file contains 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 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 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 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 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 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 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 DataError = { | |
message?: string; | |
code: string; | |
} | |
class BatchError extends Error { | |
constructor(message: string, readonly code: string) { | |
super(message) | |
} | |
} |
This file contains 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 { IncomingMessage, ServerResponse } from 'http' | |
import fetchRaw from 'node-fetch' | |
import { AcmeRouterLocation } from '@acme/router/location' | |
import { PsyContext } from '@psy/psy/context/Context' | |
import { PsyErrorMix } from '@psy/psy/error/Mix' | |
import { PsyErrorNotFound } from '@psy/psy/error/NotFound' | |
import { PsyFetcher } from '@psy/psy/fetcher/Fetcher' | |
import { PsyLog } from '@psy/psy/log/log' | |
import { psySsrClient } from '@psy/psy/ssr/client.node' |
This file contains 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
<ErrorCatcherProvider options={props.catcher}> | |
<ClGeoRootRegionsProvider value={props.rootRegions}> | |
<ClientConfigProvider value={props.clientConfig}> | |
<GoogleOptimizeProvider value={props.googleOptimize}> | |
<CookiesProvider cookies={props.cookies}> | |
<SeoTextBuilderProvider value={props.textBuilder}> | |
<AuthProvider auth={props.auth}> | |
<RouterProvider router={props.router}> | |
<BasicErrorProvider isMobile={props.isMobile}> | |
<FavoritesModalProvider isMobile={props.isMobile}> |