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

Return null/undefined from find() when the component isn't found #34

Open
pward123 opened this issue Apr 30, 2015 · 1 comment
Open

Comments

@pward123
Copy link

Is there a reason that FlowComponents.find() throws an exception when a component is not found?

I have an existing project with modal dialog support that retrieves the template name to display from a session variable. I would like to add direct component support by doing something like:

{{#if isComponentModal}}
  {{> render component=template}}
{{else}}
  {{> template}}
{{/if}}
ModalDialog.helpers.isComponentModal = function() {
  return FlowComponents.find(App.activeModalName());
}

ModalDialog.helpers.template = function() {
  return App.activeModalName();
}

However, the find call is throw an error when the component is not found. Obviously, I can just wrap the find call with a try/catch block, but it seems strange to have find() throw an error in the first place.

@pward123
Copy link
Author

pward123 commented May 4, 2015

Here's an example of what I'm talking about. I don't want the caller of openModal to know whether the modal is a component or template. Since the ComponentsStore is hidden, the only way to determine whether I'm dealing with a component is through find.

http://meteorpad.com/pad/MDHM9w4uTiyms5MED/Modal%20Dialog%20Example

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

No branches or pull requests

1 participant