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

refactor(atomic): split the atomic store into composable parts #4806

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

alexprudhomme
Copy link
Contributor

@alexprudhomme alexprudhomme commented Dec 23, 2024

https://coveord.atlassian.net/browse/KIT-3814

The atomic store was messy. The common store was way too big. There was no need for all that stuff in every store.

Copy link

github-actions bot commented Dec 23, 2024

Pull Request Report

PR Title

✅ Title follows the conventional commit spec.

Live demo links

Bundle Size

File Old (kb) New (kb) Change (%)
case-assist 243.7 243.7 0
commerce 354.8 354.8 0
search 414.8 414.8 0
insight 406 406 0
recommendation 255.9 255.9 0
ssr 408.3 408.3 0
ssr-commerce 372.1 372.1 0

SSR Progress

Use case SSR (#) CSR (#) Progress (%)
search 39 44 89
recommendation 0 4 0
case-assist 0 6 0
insight 0 27 0
commerce 0 15 0
Detailed logs search : buildInteractiveResult
search : buildInteractiveInstantResult
search : buildInteractiveRecentResult
search : buildInteractiveCitation
search : buildGeneratedAnswer
recommendation : missing SSR support
case-assist : missing SSR support
insight : missing SSR support
commerce : missing SSR support

@alexprudhomme alexprudhomme marked this pull request as ready for review December 27, 2024 15:20
@alexprudhomme alexprudhomme requested review from a team as code owners December 27, 2024 15:20
Copy link
Contributor

@fbeaudoincoveo fbeaudoincoveo left a comment

Choose a reason for hiding this comment

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

Isn't this a breaking change? Custom components can rely on store functions / attributes.

@alexprudhomme
Copy link
Contributor Author

alexprudhomme commented Jan 6, 2025

Isn't this a breaking change? Custom components can rely on store functions / attributes.

Maybe it is but this could be considered as a bug.

For example, all of those should not be available to use in the commerce store... They are only used in search & insight. Someone using them as of now in a custom component would be querying empty objects ?

    facets: {},
    numericFacets: {},
    dateFacets: {},
    categoryFacets: {},

Comment on lines 12 to 18
export interface CommonStore<StoreData> {
state: StoreData;
onChange: <PropName extends keyof StoreData>(
propName: PropName,
cb: (newValue: StoreData[PropName]) => void
) => () => void;
}
Copy link
Contributor Author

@alexprudhomme alexprudhomme Jan 6, 2025

Choose a reason for hiding this comment

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

The only real breaking change imo would be that I removed the get and set options. As written in the stencil-store documentation. These options are only there to support IE11 since it did not support Proxy...

I think I should re add those in case someone used .get() and .set() for valid store keys in custom components. And remove them in v4.

old interface

export interface CommonStencilStore<StoreData extends AtomicCommonStoreData> {
  state: StoreData;

  get: <PropName extends keyof StoreData>(
    propName: PropName
  ) => StoreData[PropName];

  set: <PropName extends keyof StoreData>(
    propName: PropName,
    value: StoreData[PropName]
  ) => void;

  onChange: <PropName extends keyof StoreData>(
    propName: PropName,
    cb: (newValue: StoreData[PropName]) => void
  ) => () => void;
}

@alexprudhomme
Copy link
Contributor Author

Isn't this a breaking change? Custom components can rely on store functions / attributes.

Maybe it is but this could be considered as a bug.

For example, all of those should not be available to use in the commerce store... They are only used in search & insight.

    facets: {},
    numericFacets: {},
    dateFacets: {},
    categoryFacets: {},

only real breaking change would be this imo https://github.com/coveo/ui-kit/pull/4806/files#r1904333364

@alexprudhomme
Copy link
Contributor Author

alexprudhomme commented Jan 8, 2025

@fbeaudoincoveo I personally feel comfortable making all the possible breaking changes in this PR. Even if a custom component was using the store, They should have never used those I removed in this PR. Someone using AtomicRecs should have never used store.facets and even if they did, that constant would have been an empty object... This is a bug. Exposed stuff that should have never been there in the first place and that are useless.

I will re add the get & set functions tho. I do agree that those could have been used for a good reason.

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.

3 participants