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

Feature request: ability to export an object from a component #19

Open
moltar opened this issue Mar 30, 2019 · 2 comments
Open

Feature request: ability to export an object from a component #19

moltar opened this issue Mar 30, 2019 · 2 comments

Comments

@moltar
Copy link

moltar commented Mar 30, 2019

Instead of:

export default [ componentName ]

Would be great to be able to do:

export default { componentName }

The use case is that the component can then be much easier consumed from another component by name.

E.g.:

// component-two.ts

import { componentOneService } from './component-one'

// now can do something with component's data
componentOneService.metadata.name

What do you think?

Can just maybe call Object.values() on the component default export, if it's not array.

@tommy351
Copy link
Owner

tommy351 commented Apr 1, 2019

Instead of exporting all variables in default, you can use named exports.

// component-one.js
export const componentOneService = new Service();

// component-two.js
import { componentOneService } from './component-one';

@moltar
Copy link
Author

moltar commented Apr 1, 2019

Right, of course. But would kosko then pick them up? Or do I need to still have the default export with an array?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants