Function ReactiveImage

Reactively load an Image with access to loading / error state.

Usage in a component

import { ReactiveImage } from 'reactiveweb/image';
<template>
{{#let (ReactiveImage 'https://path.to.image') as |state|}}
{{#if imgState.isResolved}}
<img src={{imgState.value}}>
{{/if}}
{{/let}}
</template>

Usage in a class

import { use } from 'ember-resources';
import { ReactiveImage } from 'reactiveweb/image';

class Demo {
@use imageState = ReactiveImage('https://path.to.image');
}

Reactive usage in a class

import { tracked } from '@glimmer/tracking';
import { use } from 'ember-resources';
import { ReactiveImage } from 'reactiveweb/image';

class Demo {
@tracked url = '...';
@use imageState = ReactiveImage(() => this.url);
}
  • Parameters

    • Rest...args: [maybeUrl: string | (() => string)]

    Returns {
        get isError(): boolean;
        get isLoading(): boolean;
        get isResolved(): boolean;
        get value(): unknown;
    }

    • get isError(): boolean
    • get isLoading(): boolean
    • get isResolved(): boolean
    • get value(): unknown