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

Common Registry interface #39059

Closed
wants to merge 17 commits into from
Closed

Common Registry interface #39059

wants to merge 17 commits into from

Conversation

streamich
Copy link
Contributor

@streamich streamich commented Jun 17, 2019

Summary

  • Implements common Registry interface.
  • Replaces IndexPatternCreationConfigRegistry uiRegistry by Registry@mattkime
  • Uses Registry interface for all Embeddables registries — @stacey-gammon

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

@streamich streamich requested a review from a team as a code owner June 17, 2019 06:59
@streamich streamich added the release_note:skip Skip the PR/issue when compiling release notes label Jun 17, 2019
@streamich streamich changed the title Registries 3 Common Registry interface Jun 17, 2019
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@lizozom lizozom left a comment

Choose a reason for hiding this comment

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

Love this PR.
Where is freeze going to be used?

@streamich
Copy link
Contributor Author

@lizozom

Would be used like Tim suggested to freeze registries after setup life-cycle.

Copy link
Contributor

@lizozom lizozom left a comment

Choose a reason for hiding this comment

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

The PR looks great.
I'm a bit skeptical of having freeze here, as there's no immediate use.
But @streamich mentioned @timroes and @epixa want it for some planned uses.

So LGTM.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

filterBy,
set,
clear,
set$: (set$ as unknown) as Observable<T>,
Copy link
Contributor

Choose a reason for hiding this comment

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

What would this be used for?

Also if you define a type parameter for the new Subject<T>() above, you should be able to use the .asObservable() method instead of having to cast like this. That will also ensure that there is no access to the next method outside this module.

Copy link
Contributor Author

@streamich streamich Jun 19, 2019

Choose a reason for hiding this comment

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

What would this be used for?

Most likely user would be actionsRegistry in Embeddables where in Phase II users can add actions dynamically at runtime.

Also if you define a type parameter for the new Subject<T>() above, [..]

Yeah, I forgot <T>.

That will also ensure that there is no access to the next method outside this module.

That's why I'm upcasting to Observable<T> it "removes" .next() method without creating a new observable.

import { Observable, Subject } from 'rxjs';
import { Registry, Predicate } from './types';

export const createRegistry = <T>(): Registry<T> => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Overall, I primarily want to make sure we're not solving a more complicated problem than we need to. There are some choices that I'm a bit unclear about. What is the advantage of using generators instead of simply returning arrays? Do we benefit from providing an id when adding items? Why provide separate observables for set and clear?

Copy link
Contributor Author

@streamich streamich Jun 19, 2019

Choose a reason for hiding this comment

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

I guess we discussed registries at our meeting already. But for posterity:

What is the advantage of using generators instead of simply returning arrays?

This implementation handles all our registry use cases (uiRegistry, kbn-interpreter registries, and other ad-hoc registries).

Do we benefit from providing an id when adding items?

Because in all registries (I believe) records can be identified by ID, and in some uiRegistries and all kbn-interpreter registries records are also accessed by ID. So, registries are effectively key-value stores.

Why provide separate observables for set and clear?

🤷‍♀️ Just one way of doing it.

@streamich
Copy link
Contributor Author

Closing this as we went ahead without a common registry implementation instead: #39168

@streamich streamich closed this Jun 19, 2019
@streamich streamich deleted the registries-3 branch June 19, 2019 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants