跳到主要内容

tryGetEntityStatus()

function tryGetEntityStatus<T>(target): EntityStatus<T> | undefined;

Defined in: packages/rxdb/src/rxdb-utils.ts:131

探测实体状态:查不到返回 undefined,不抛错。

Type Parameters​

Type Parameter
T extends EntityType

Parameters​

ParameterTypeDescription
targetunknown任意对象;不要求它是已挂载的实体

Returns​

EntityStatus<T> | undefined

实体状态对象,没有则 undefined

Remarks​

同 tryGetEntityMetadata:getEntityStatus 改成 fail-fast 之后, 那些本来就写了 if (!status) 分支的调用点要显式改用这个入口 —— 它们的守卫此前对类型系统是不可见的(声明说非空), 换过来之后守卫才真正被类型检查覆盖。