SHARE
TWEET

Untitled

a guest Jun 17th, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { RootStoreState, ProductStoreSelectors} from 'src/app/stores';  
  2.  
  3. this.store$.pipe(select(ProductStoreSelectors.getSelectedProduct())).subscribe((value) => {
  4.     console.log(value)
  5. })
  6.      
  7. export const featureAdapter: EntityAdapter<IProduct> = createEntityAdapter<IProduct>({
  8.   selectId: model => model.id,
  9. });
  10.  
  11. export const selectProductState: MemoizedSelector<object, State> = createFeatureSelector<State>('products');
  12.  
  13. export const getSelectedProduc = () => createSelector(
  14.   selectProductState,
  15.   (state: State) => state.selectedProduct
  16. );
  17.      
  18. export interface State extends EntityState<IProduct> {
  19.   selectedProduct: IProduct;
  20. }
  21.      
  22. function memoized() {
  23.         if (!lastArguments) {
  24.             lastResult = projectionFn.apply(null, arguments);
  25.             lastArguments = arguments;
  26.             return lastResult;
  27.         }
  28.         if (!isArgumentsChanged(arguments, lastArguments, isArgumentsEqual)) {
  29.             return lastResult;
  30.         }
  31.         lastArguments = arguments;
  32.         var newResult = projectionFn.apply(null, arguments);
  33.         if (isResultEqual(lastResult, newResult)) {
  34.             return lastResult;
  35.         }
  36.         lastResult = newResult;
  37.         return newResult;
  38.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top