How to use the ngrx-forms.AddArrayControlAction.TYPE function in ngrx-forms

To help you get started, we’ve selected a few ngrx-forms 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 MrWolfZ / ngrx-forms / example-app / src / app / dynamic / dynamic.reducer.ts View on Github external
array(
    s = { maxIndex: 2, options: [1, 2] },
    a: AddArrayControlAction | RemoveArrayControlAction,
  ) {
    switch (a.type) {
      case AddArrayControlAction.TYPE: {
        const maxIndex = s.maxIndex + 1;
        const options = [...s.options];
        // tslint:disable-next-line:no-unnecessary-type-assertion
        options.splice(a.index!, 0, maxIndex);
        return {
          maxIndex,
          options,
        };
      }

      case RemoveArrayControlAction.TYPE: {
        const options = [...s.options];
        // tslint:disable-next-line:no-unnecessary-type-assertion
        options.splice(a.index!, 1);
        return {
          ...s,