/*
 * Copyright (C) 2018 Robert Bosch GmbH Copyright (C) 2018 Robert Bosch Manufacturing Solutions GmbH, Germany. All rights reserved.
 */

import { Observable } from 'rxjs';

/**
 * This interface is used by {@link MasterDetailViewComponent} to load objects into the {@Link MasterViewComponent} and the {@Link DetailViewComponent} respectively.
 */
export interface MasterDetailResource<T, Query, QuerySingle> {
  /**
   * queryAll is called by {@link MasterDetailViewComponent} to load a collection of objects into the {@Link MasterViewComponent}.
   * @param query to select some resources
   * @returns an observable containing all entries
   */
  queryAll(query?: Query): Observable<T[]>;

  /**
   * querySingle is called when the user clicks on a object shown in the {@Link MasterViewComponent}.
   * @param query to select a single resource
   * @returns an observable containing a single entry
   */
  querySingle(query?: QuerySingle): Observable<T>;
}
