-
Notifications
You must be signed in to change notification settings - Fork 35
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
Export renderer in own namespace #207
Export renderer in own namespace #207
Conversation
@sgratzl and @thinkh : I've removed the I found a similar problem here microsoft/TypeScript#5711 and in this issue they state that we need more explicit type annotations can one of you fix the type annotations if they are really causing our problem because I don't really know where to start at the moment |
I just noticed that LineUp v3 is using an older version of the lineupengine. LineUp v3: Line 141 in 85df597
LineUp v4: Line 149 in 0cfa222
I don't know the changes between lineupengine v1 and v2. Hence, as @lehnerchristian suggested, we might need to change/add some typings over there. |
…upv4_remove_internal_from_renderers
on purpose since lineupengine v2 is designed to work with lineup v4 |
@lehnerchristian Is this done from your side? |
@thinkh , looks good as far as I can tell after this long time |
what are the use cases again for exporting all renderers? In case of overriding them, most implement just the three factory functions, so in case one subclasses that, one doesn't gain much. Moreover, an alternative would be use just wrap one instance of an renderer with another one. Similar to the toolbar one can have access to all the registered renderers using the e.g. const base = defaultOptions().renderers.number;
...
renderers: {
'mynumber': {
title: 'mynumber',
canRender: base.canRender.bind(base),
create: base.canRender.bind(base),
createGroup: base.canRender.bind(base),
}
} or const base = defaultOptions().renderers.number;
class MyNumberR extends base.construtor {
...
} |
@sgratzl I understand your point that a renderer exposes only three methods and it might not be worth the opening. However, to me your suggested example looks like a different implementation pattern and unfamiliar if one is used to TypeScript where you can just import and extend a class or implement an interface. Furthermore, as a developer I would never guess that I can override or define a renderer like you suggested and would rather browse the API documentation. @lehnerchristian and @puehringer Could you do the implementation in your app with the |
@sgratzl @thinkh I indeed didn't know about these ways of renderer access/extensions. I will try to refactor the current implementation and check if it is more convenient this way. |
I also didn't know / think of these ways. I'll try them too |
Models are complex objects with various methods and business logic. Renderers are simple and since it is a flat export of lineupjs it is already getting pretty big. Moreover, when I think about it, there is no need to have proper classes for renderers after all, since they are singleton instances and usually no inheritance. So, the more I export "officially" the less I can change in the future. like the call the base renderer in a composition style is easier than using it as a base class. |
as a compromise one could expose them under a sub namespace. e.g. all the builder helper functions and classes are exported under the |
@sgratzl Your compromise sounds like a plan. I'm not sure at the moment how to implement this. Can you please provide an example of the namespace? |
@sgratzl @thinkh I think the exporting in a certain namespace is a good idea, as I am currently facing some issues porting apps to lineup#v4. As already discussed, some functions were annotated with Some of these functions however are very essential (for advanced use-cases) such as: Do you think it would be possible to (selectively) export functions in their particular namespace? |
please open another issue or lets discuss that in person. I don't want to discuss things that are not PR related in a PR since the PR will be closed when it is merged. |
@sgratzl For the specific exports I will create separate tickets of course, but I was just listing a few examples supporting the namespace idea discussed above. |
@sgratzl I reverted the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes that was the basic idea. Tho, I don't guarantee a stable API behind any namespaces. So a breaking change in a function or renderer won't lead to a major version update.
@sgratzl If you are fine with the changes, you can proceed and merge this PR. |
closes #208
prerequisites:
Summary