How to use the @ngrx/store.union function in @ngrx/store

To help you get started, we’ve selected a few @ngrx/store examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github devonfw / my-thai-star / angular / src / app / book-table / store / actions / book-table.actions.ts View on Github external
'[InviteFriends] Invite friends',
  props<{ booking: Booking }>(),
);

export const inviteFriendsSuccess = createAction(
  '[InviteFriends] Invite friends success',
  props<{ bookingResponse: BookingResponse }>(),
);

export const inviteFriendsFail = createAction(
  '[InviteFriends] Invite friends Fail',
  props<{ error: Error }>(),
);

// action types
const all = union({
  bookTable,
  bookTableSuccess,
  bookTableFail,
  inviteFriends,
  inviteFriendsSuccess,
  inviteFriendsFail,
});
export type BookTableActions = typeof all;
github devonfw / my-thai-star / angular / src / app / sidenav / store / actions / send-order.actions.ts View on Github external
export const sendOrders = createAction(
  '[SendOrder] Load SendOrders',
  props<{ token: string }>(),
);

export const sendOrdersSuccess = createAction(
  '[SendOrder] Load SendOrders Success',
);

export const sendOrdersFail = createAction(
  '[SendOrder] Load SendOrders Fail',
  props<{ error: string }>(),
);

// action types
const all = union({
  sendOrders,
  sendOrdersSuccess,
  sendOrdersFail,
});
export type SendOrdersAction = typeof all;
github devonfw / my-thai-star / angular / src / app / sidenav / store / actions / order.actions.ts View on Github external
);

export const deleteOrder = createAction(
  '[Order] Delete Order',
  props<{ id: string }>(),
);

export const deleteOrders = createAction(
  '[Order] Delete Orders',
  props<{ ids: string[] }>(),
);

export const clearOrders = createAction('[Order] Clear Orders');

// action types
const all = union({
  loadOrders,
  addOrder,
  addOrders,
  updateOrder,
  updateOrders,
  deleteOrder,
  deleteOrders,
  clearOrders,
});
export type OrdersAction = typeof all;
github devonfw / my-thai-star / angular / src / app / menu / store / actions / menu.actions.ts View on Github external
'[Menu] Load Menus Success',
  props<{ pageable?: Pageable; content?: DishView[] }>(),
);

export const loadMenusFail = createAction(
  '[Menu] Load Menus Fail',
  props<{ error: Error }>(),
);

export const updateDishExtras = createAction(
  '[Menu] Select Dish Extras',
  props<{ dish: DishView }>(),
);

// action types
const all = union({
  loadMenus,
  loadMenusSuccess,
  loadMenusFail,
  updateDishExtras,
});
export type MenuActions = typeof all;
github devonfw / my-thai-star / angular / src / app / user-area / store / actions / auth.actions.ts View on Github external
);

export const logout = createAction('[Auth] Logout');

export const logoutFail = createAction(
  '[Auth] LogoutFail',
  props<{ error: Error }>(),
);

export const verifyTwoFactor = createAction(
  '[Auth] VerifyTwoFactor',
  props<{ username: string; password: string }>(),
);

// action types
const all = union({
  openDialog,
  closeDialog,
  login,
  loginSuccess,
  loginFail,
  token,
  logout,
  logoutFail,
  verifyTwoFactor,
});
export type AuthActions = typeof all;
github ngrx / platform / modules / store / spec / reducer_creator.spec.ts View on Github external
it('should support reducers with multiple actions', () => {
        const both = union({ bar, foo });
        const func = (state: {}, action: typeof both) => ({});
        const result = on(foo, bar, func);
        expect(result.types).toContain(bar.type);
        expect(result.types).toContain(foo.type);
      });
    });
github ngrx / platform / modules / store / spec / action_creator.spec.ts View on Github external
it('should narrow the action', () => {
      const foo = createAction('FOO', props<{ foo: number }>());
      const bar = createAction('BAR', props<{ bar: number }>());
      const both = union({ foo, bar });
      const narrow = (action: typeof both) => {
        if (action.type === foo.type) {
          expect(action.foo).toEqual(42);
        } else {
          throw new Error('Should not get here.');
        }
      };

      narrow(foo({ foo: 42 }));
    });