Skip to content
module@warp-drive/ember

Interface EmberRequestArgs<RT, E> ​

ts
interface EmberRequestArgs<RT, E> extends RequestArgs<RT, E> {
  chrome?: ComponentLike<{
  Args: {
     features: ContentFeatures<RT>;
     state: RequestState | null;
  };
  Blocks: {
     default: [];
  };
}>;
}

Defined in: warp-drive-packages/ember/dist/index.d.ts:56

The args accepted by the `<Request />` component.

Every arg is optional, but either @request or @query is needed for the component to leave the idle state, and a store must be available via @store, context, or the store service.

ArgTypePurpose
@requestFutureA request already made via store.request to monitor
@queryStoreRequestInputA request for the component to make and monitor
@storeStore or RequestManagerThe store to make requests with
@subscriptionRequestSubscriptionA subscription to render in place of creating one
@autorefreshboolean or stringWhen to automatically refresh the request
@autorefreshThresholdnumberHow long in ms before an autorefresh happens
@autorefreshBehavior'refresh', 'reload' or 'policy'How autorefresh fetches
@chromeComponentA component that wraps every state's block

All but @chrome are inherited from RequestArgs and documented on the members below.

Example ​

gts
import { Request } from '@warp-drive/ember';
import { findRecord } from '@warp-drive/utilities/json-api';

<template>
  <Request
    @query={{findRecord "user" @userId}}
    @autorefresh="online,interval"
    @autorefreshThreshold={{60_000}}
    @autorefreshBehavior="refresh"
  >
    <:content as |result|>{{result.data.name}}</:content>
    <:error as |error|>{{error.message}}</:error>
  </Request>
</template>

Extends ​

  • RequestArgs<RT, E>

Type Parameters ​

RT ​

RT

E ​

E

Properties ​

chrome? ​

ts
optional chrome?: ComponentLike<{
  Args: {
     features: ContentFeatures<RT>;
     state: RequestState | null;
  };
  Blocks: {
     default: [];
  };
}>;

Defined in: warp-drive-packages/ember/dist/index.d.ts:78

A component that wraps whichever block is rendered, so shared UI such as a layout or a refresh indicator stays mounted as the request moves between states. It yields to its default block where the state's block renders.

It receives @state, the RequestState (null while idle), and @features, the ContentFeatures used to refresh, reload, or abort the request.

gts
const Chrome = <template>
  <div class={{if @features.isRefreshing "is-refreshing"}}>{{yield}}</div>
</template>;

<template>
  <Request @request={{@request}} @chrome={{Chrome}}>
    <:content as |result|>{{result.data.name}}</:content>
  </Request>
</template>

Released under the MIT License.