Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client config - unique maps #1613

Merged
merged 26 commits into from
Mar 16, 2023

Conversation

pileks
Copy link
Contributor

@pileks pileks commented Mar 8, 2023

Closes #1283

This PR aims to change the envs and interfaces collections inside CoreClientConfig into readonly unique maps/map-like structures.

It achieves this by introducing the concept of UriMaps:

class UriMap<TValue>
  implements Map<Uri, TValue>, ReadonlyUriMap<TValue> {
//...
}

export type ReadonlyUriMap<T> = ReadonlyMap<Uri, T>;

envs is now essentially:

  readonly envs?: ReadonlyUriMap<WrapperEnv>;

interfaces is now essentially:

  readonly interfaces?: ReadonlyUriMap<readonly Uri[]>;

Everything that can be is marked as readonly in order to relay the intended readonly nature of the CoreClientConfig.

All of this boils down to the fact that the way we instantiate a new CoreClientConfig now looks like this:

const config: CoreClientConfig = {
  resolver: ...,
  envs: new ReadonlyUriMap<WrapperEnv>([
    [
      new Uri("wrap://someuri"),
      {
        //env
      }
    ],
    [
      new Uri("wrap://someuri2"),
      {
        //env2
      }
    ],
  ]),
  interfaces: new ReadonlyUriMap<Uri[]>([
    [
      new Uri("wrap://someuri"),
      [
        new Uri("wrap://someimpl1"),
        new Uri("wrap://someimpl2"),
        new Uri("wrap://someimpl3"),
      ]
    ],
    [
      new Uri("wrap://someuri2"),
      [
        new Uri("wrap://someimpl1"),
        new Uri("wrap://someimpl2"),
        new Uri("wrap://someimpl3"),
      ]
    ]
  ])
};

@pileks pileks requested a review from cbrzn March 8, 2023 14:04
@pileks pileks self-assigned this Mar 8, 2023
@pileks pileks marked this pull request as ready for review March 8, 2023 16:43
Niraj-Kamdar
Niraj-Kamdar previously approved these changes Mar 12, 2023
Copy link
Contributor

@Niraj-Kamdar Niraj-Kamdar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a really good improvement over existing list of objects structure!

dOrgJelli
dOrgJelli previously approved these changes Mar 16, 2023
Copy link
Contributor

@dOrgJelli dOrgJelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super nice 👏

@dOrgJelli dOrgJelli merged commit b55961a into origin-dev Mar 16, 2023
@dOrgJelli dOrgJelli deleted the pileks/feat/js-client-config-unique-maps branch April 10, 2023 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JS Client: Client Config Should Use Unique Maps Instead Of Unique Arrays
3 participants