本文整理汇总了TypeScript中@jonggrang/task.bracket函数的典型用法代码示例。如果您正苦于以下问题:TypeScript bracket函数的具体用法?TypeScript bracket怎么用?TypeScript bracket使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bracket函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: action
export function withFileInfoCache<A>(
delay: number,
action: (getInfo: (hash: number) => (path: string) => T.Task<FileInfo>) => T.Task<A>
): T.Task<A> {
return delay === 0
? action(constant(getFileInfo))
: T.bracket(initialize(delay), terminate, s => action(getAndRegisterInfo(s)));
}
示例2: runServer
export function runServer(
settings: Z.Settings,
server: Server | HServer,
app: W.Application,
ii1: Z.InternalInfo1
): T.Task<void> {
return T.bracket(
T.pure(createServerState(settings, app, ii1, server)),
shutdownServer,
state => connectAndTrapSignal(state, settings)
);
}
示例3: action
export function withFdCache<A>(duration: number, action: (_: GetFd) => T.Task<A>): T.Task<A> {
return duration === 0
? action(P.constant(getFdNothing))
: T.bracket(initialize(duration), terminate, mfc => action(getFd(mfc)));
}
示例4: bracket
export function withAVar<A, B>(avar: AVar<A>, act: (_: A) => Task<B>): Task<B> {
return bracket(takeAVar(avar), v => putAVar(avar, v), act);
}