Binary.ViewFunction
BinaryCreates a view function that can be intercepted by the OnInvoke handler defined on a Binary.View.
Syntax
Binary.ViewFunction(function as function) as functionParameters
| Name | Type | Required | Description |
|---|---|---|---|
function | function | Yes | The function to wrap for view-aware execution within a Binary.View. |
Return Value
function — A view-aware wrapper function that integrates with the Binary.View infrastructure.
Remarks
Binary.ViewFunction creates a view function based on the given function that can be handled within a view created by Binary.View. This is the binary-stream equivalent of Table.ViewFunction.
The OnInvoke handler of Binary.View can be used to define custom handling for the view function. When the wrapped function is invoked on a binary view:
1. If the view has an OnInvoke handler that handles the view function, it is called. 2. If no OnInvoke handler is specified, or if it does not handle the view function, or if the handler raises an error, the original function is applied on top of the view using default behavior.
This function is primarily used in custom connector development to expose source-specific binary operations that can be folded back to the data source.
Refer to the published Power Query custom connector documentation for a more complete description of Binary.View and custom view functions.
Examples
Example 1: Create a view function for a binary view
let
// Define a view function that reads a specific section
ReadSection = Binary.ViewFunction((binary, offset, size) =>
Binary.Range(binary, offset, size)
),
// Create a view with an OnInvoke handler
View = Binary.View(
null,
[
GetStream = () => Binary.FromList({0..99}),
OnInvoke = (function, args) =>
if function = ReadSection then
Binary.Range(Binary.FromList({0..99}), args{1}, args{2})
else
...
]
)
in
ReadSectionReturns the ReadSection view function, which can now be applied to the binary view and handled by OnInvoke.
Value | |
|---|---|
| 1 | Function |