本文整理汇总了TypeScript中mobx.useStrict函数的典型用法代码示例。如果您正苦于以下问题:TypeScript useStrict函数的具体用法?TypeScript useStrict怎么用?TypeScript useStrict使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了useStrict函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: handleResult
function handleResult(res) {
t.is(res, resultValue)
t.deepEqual(coffees, producedCoffees)
const filtered = filterRelevantStuff(events)
t.snapshot(filtered, "Wrong events, expected\n" + JSON.stringify(filtered, null, 2))
useStrict(false)
t.end()
}
示例2: testCoffeeTodo
function testCoffeeTodo(
t: CallbackTestContext & Context<any>,
generator: (self: any) => (x: string) => IterableIterator<any>,
shouldError: boolean,
resultValue: any,
producedCoffees: string[]
) {
useStrict(true)
const Todo = types
.model({
title: "get coffee"
})
.actions(self => ({
startFetch: flow(generator(self))
}))
const events: any[] = []
const coffees: string[] = []
const t1 = Todo.create({})
unprotect(t1)
addMiddleware(t1, (c, next) => {
events.push(c)
return next(c)
})
reaction(() => t1.title, coffee => coffees.push(coffee))
function handleResult(res) {
t.is(res, resultValue)
t.deepEqual(coffees, producedCoffees)
const filtered = filterRelevantStuff(events)
t.snapshot(filtered, "Wrong events, expected\n" + JSON.stringify(filtered, null, 2))
useStrict(false)
t.end()
}
t1.startFetch("black").then(
r => {
t.is(shouldError, false, "Ended up in OK handler")
handleResult(r)
},
r => {
t.is(shouldError, true, "Ended up in ERROR handler")
console.error(r)
handleResult(r)
}
)
}
示例3: useStrict
import { useStrict } from 'mobx';
useStrict(true);