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

Flyweight #42

Closed
pgarciacamou opened this issue Jun 26, 2017 · 2 comments
Closed

Flyweight #42

pgarciacamou opened this issue Jun 26, 2017 · 2 comments

Comments

@pgarciacamou
Copy link
Owner

Shouldn't heuristics just say whether or not something should be added or done? Right now it seems like create only calls the heuristic with the arguments and that is it.

I think it should be like:

function Flyweight(...args) {
  this.flyweights = {};
  options.constructor.apply(this, args);
}
extend(Flyweight.prototype, {
  create(name, obj) {
    let allow = this.heuristic(name);
    if(allow) {
      return this.flyweights[name] = this.flyweights[name] = obj;
    }
  },
  heuristic() {
    return true;
  }
});
@pgarciacamou
Copy link
Owner Author

After finishing the refactor, let's update the API in the docs.

@pgarciacamou
Copy link
Owner Author

done in #41

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