locateResource()
Locate a given resource and give you extra information such as absolute page index, relevant nodes, offset etc. This is most useful when you want to locate resources such as CFI.
This method is live, it will return an observable that emits every time the reader layout.
const consolidatedResource$ = reader.locateResource(resource, options)
Reference
locateResource(resource, options)
type CfiLocatableResource = {
cfi: string
}
export type LocatableResource = SpineItem | CfiLocatableResource
export type ConsolidatedResource = CfiLocatableResource & {
itemIndex?: number
itemPageIndex?: number
absolutePageIndex?: number
startNode?: Node
startOffset?: number
range?: Range
}
locateResource(resource, options)
Parameters
resource
: An object or array of objects that extendsLocatableResource
. When using a cfi, all resources sharing the same cfi will share the same consolidation stream.options?
:mode?:
"shallow" | "load" : Defaultload
. Shallow means that the item will not be loaded if needed, load will force load an item. By using shallow you avoid loading documents excessively but you will only get the values as precise as possible with the current reader state.
Returns
Observable<{ resource: T; meta: ConsolidatedResource }>
Or if you passed an array of resources
Observable<{ resource: T; meta: ConsolidatedResource }[]>
An observable containing the initial resources and their consolidated metadata.
Last updated
Was this helpful?