-
Notifications
You must be signed in to change notification settings - Fork 10
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
Some ideas for a future release #28
Comments
Hi @RomainLanz, glad you like it 😃 The only one I feel needs a bit of clarification is "4. Defines the transformer for collection and item". I'd be interested in your use case and your view on this. Otherwise, really like your proposals and would happily accept PRs for them. Unfortunately, I'm currently really busy with work for the university, so I won't be able to spend much time on it in the next few months. But if you are able to do some work that would be awesome! |
Sure I'll work on those PRs during this week.
I can understand the point of view that you define a schema for an item and a collection is a list of this item. My use case is the item when requested alone, give a lot more information than when it's requested via a list. As a real example, I'm creating a CMS that can handle an article in a different language. Calling [
{
id: 1,
headline: '...',
thumbnail: '...',
featured_thumbnail: '...',
translations: ['fr', 'en']
published_at: '...',
featured: false,
},
...
] In the meanwhile, calling {
id: 1,
headline: '...',
description: '...',
body: '...',
thumbnail: '...',
featured_thumbnail: '...',
translations: ['fr', 'en']
published_at: '...',
sources: [...],
...
} Therefore, having only one transformer isn't possible because the schema change between one item or a collection of this item. |
You're awesome 👍 😃 As to your example, I did have a similar case with blog posts once where I also didn't want the body of the post in the collection view. My solution was to use an But I can see how it can be useful in some cases. I would be willing to accept a PR if it keeps the existing API where |
After more reflexion, I'm thinking about having a By default This could also help when you have two different output for casual and admin. |
I like this. It is definitely a more flexible way of implementing this. I'm sure you will come up with something awesome! Go ahead. 😃 |
@RomainLanz I finally have a few hours of free time, I think I'll give feature 4 "multiple transformers" a try. 😃 |
That's awesome! Also, it seems that the code I've added to directly use the IoC instead of passing an instance isn't working. I'll need to take a look. |
For everyone whos interested in checking out these new features: The updated documentation can be found in the next branch and a beta version for 2.0.0 is available on npm. Feedback and bug reports are highly appreciated. |
Since all features proposed here are now implemented, I'll close this issue. Please open a new issue to report bugs in the beta version. |
Hey all 👋
First of all, thanks for this package. It's really useful and helps to keep an API consistent and simple.
I've been working with Bumblebee for some projects and found some things that could be changed to improve the developer experience. I can work on them if they are accepted.
1. Accept namespace instead of an instance of transformers
Currently, we need to require the transformer in our controller (or another transformer) and then use this require to use it.
It could be better to directly use the namespace.
2. Rename method toArray => toJSON
When we use the fluent interface the latest method to call is named
toArray()
. In fact, this method transforms your object to JSON syntax, so it would be better to name ittoJSON()
.3. Use JS getter
When we define our own transformer we make use of JS method. In the meanwhile, using static JS getter would be way faster (~2x).
4. Defines the transformer for collection and item
Currently, we have only one
transform
method inside our custom transformer. It could be better to have atransformCollection
andtransformItem
when you need a different schema for a collection and an item.For the moment, you need to create two transformers
ArticleItemTransformer
ArticleCollectionTransformer
.Let me know what you think about them.
The text was updated successfully, but these errors were encountered: