本文整理汇总了TypeScript中ffi.Callback函数的典型用法代码示例。如果您正苦于以下问题:TypeScript Callback函数的具体用法?TypeScript Callback怎么用?TypeScript Callback使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Callback函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('success: A Logger Class can be cast to a C void pointer', () => {
let count = 0
const _logFn = (_level: number,
_target: string,
_message: string,
_modulePath: string,
_file: string,
_line: number) => {
count = count + 1
console.log('level: ' + _level)
console.log('target: ' + _target)
console.log('message: ' + _message)
console.log('modulePath: ' + _modulePath)
console.log('file: ' + _file)
console.log('line: ' + _line)
}
const logFnCb = ffi.Callback('void', ['int', 'string', 'string', 'string', 'string', 'int'], _logFn)
const logger = new Logger()
logger.logFn = logFnCb
const loggerPtr: any = loggerToVoidPtr(logger)
const level = 123
const target = 'target'
const message = 'message'
const modulePath = 'modulePath'
const file = 'file'
const line = 456
loggerFunction(loggerPtr, level, target, message, modulePath, file, line)
})
示例2: createInitCallback
export function createInitCallback(callback: Function)
{
return ffi.Callback(
ref.types.void
, [GkeyCode, wchar_string, 'void *']
, callback
);
}
示例3: reject
(resolve, reject) => ffi.Callback('void', ['uint32', 'uint32', 'string'],
(xcommandHandle: number, err: number, info: any) => {
if (err) {
reject(err)
return
}
resolve(info)
})
示例4: Callback
(resolve, reject) => Callback(
'void',
['uint32','uint32'], (xhandle: number, err: number) => {
if (err) {
reject(err)
return
}
resolve()
})
示例5: reject
(resolve, reject) => ffi.Callback(
'void',
['uint32', 'uint32', 'uint32'],
(handle: number, err: number, state: StateType) => {
if (err) {
reject(err)
}
resolve(state)
})
示例6: reject
(resolve, reject) => ffi.Callback(
'void',
['uint32', 'uint32', 'uint32'],
(xHandle: number, err: number, handle: number) => {
if (err) {
reject(err)
}
resolve(handle)
})
示例7: Callback
(resolve, reject) => Callback(
'void',
['uint32','uint32','string'],
(xhandle: number, err: number, fees: string) => {
if (err) {
reject(err)
return
}
resolve(fees)
})
示例8: it
it(`a call to vcx_connection_get_state should return ${VCXCode.INVALID_CONNECTION_HANDLE}`, () => {
const result = run.ffi.vcx_connection_update_state(
0,
1,
ffi.Callback(
'void',
['uint32', 'uint32', 'uint32'],
(xhandle: number, err: number, state: number) => null
)
)
assert.equal(result, VCXCode.INVALID_CONNECTION_HANDLE)
})