本文整理匯總了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);
}