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

Pass through arguments to Instantiate the given class #24

Open
yorkie opened this issue Jul 6, 2017 · 0 comments
Open

Pass through arguments to Instantiate the given class #24

yorkie opened this issue Jul 6, 2017 · 0 comments

Comments

@yorkie
Copy link
Owner

yorkie commented Jul 6, 2017

Here is the demo function:

// utils for pass a class constructor and arguments, and return the
// instance of the given class.
function passthroughModule(initializer, args) {
  return new (Function.prototype.bind.apply(initializer, [null].concat(args)));
}

Then we would use this function:

class Foo { ... }
passthroughModule(Foo, args);
@yorkie yorkie changed the title How to pass through the arguments to Instantiate the given class pass through the arguments to Instantiate the given class Jul 6, 2017
@yorkie yorkie changed the title pass through the arguments to Instantiate the given class pass through arguments to Instantiate the given class Jul 6, 2017
@yorkie yorkie changed the title pass through arguments to Instantiate the given class Pass through arguments to Instantiate the given class Jul 6, 2017
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

1 participant