📘
prose
  • Get Started
    • Introduction
    • Demo & Showcase
    • Contact / Community / Links
    • Getting started
    • Core concepts
    • Troubleshooting / FAQ
  • Alternatives
  • Learn
    • Core
    • Streamer
      • Node
      • React Native
      • Service Worker
      • Web (dom)
      • Hooks
    • Enhancers
    • Viewport
    • Hooks
    • Pagination
    • Settings
    • Context
    • Navigation
    • Selection
    • Links
    • Zoom
    • PDF
  • CORE API
    • reader
      • links$
      • locateResource()
    • viewport
    • navigation
  • zoom
  • enhancers
    • PDF
    • Gestures
    • Gallery
    • Search
    • Annotations
    • Bookmarks
  • React Reader
    • Introduction
    • Getting Started
  • CFI
    • About
Powered by GitBook
On this page
  • Reference
  • Parameters
  • Returns

Was this helpful?

  1. CORE API
  2. reader

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
  endCfi?: 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 extends LocatableResource.

  • options? :

    • mode?: "shallow" | "load" : Default load. 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.

Previouslinks$Nextviewport

Last updated 2 months ago

Was this helpful?