MethodsDynamic Display Method | Fire Snippets Docs
Dynamic Display Method
Displays dynamic data using templates with optional real-time updates.
dynamicDisplay(snippetId, variables, onUpdate)
Description
Dynamically displays data from a Firestore collection by rendering items based on a provided template. Supports conditional rendering and real-time updates.
Method Signature
Parameters
- snippetId: (string) The ID of the dynamic display snippet configuration.
- variables: (Array) An array of objects containing variable names and values to replace placeholders in the Firestore path, query conditions, or templates.
- onUpdate: (function) A callback function that is called whenever data is fetched or updated. Receives the data array as a parameter.
Returns
- Promise: Resolves with an object containing an
unsubscribe
method to stop real-time updates, or rejects with an error.
Usage Example
HTML Elements Required
Ensure your HTML includes the container element specified in your snippet configuration:
Template Syntax: The dynamicSnippetItemCode
should use #fieldName
placeholders to insert data and supports conditional rendering with if
, else if
, and else
blocks.
Example template:
Was this helpful?
Next