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

can.Compute as a prototype based can.compute #1255

Closed
alexisabril opened this Issue Oct 3, 2014 · 7 comments

Comments

Projects
None yet
5 participants
@alexisabril
Contributor

alexisabril commented Oct 3, 2014

Creating an issue to track the following feature:

Refactor can.compute to instead have existing methods on a prototype, as opposed to creating closure scoped methods upon each compute.

For example:

var c = can.compute(1)

would change to

var c = new can.Compute(1)

can.compute API will still be supported, however can.compute internals will be mapped to can.Compute.

@alexisabril alexisabril self-assigned this Oct 3, 2014

@alexisabril alexisabril added this to the 2.2.0 milestone Oct 3, 2014

@rjgotten

This comment has been minimized.

Show comment
Hide comment
@rjgotten

rjgotten Oct 23, 2014

You can't really set up a prototype chain where a class inherits from Function.
This:

var c = new can.Compute(1)

would never work, if you wanted to be able to execute c directly to grab its current value, e.g. var val = c().

rjgotten commented Oct 23, 2014

You can't really set up a prototype chain where a class inherits from Function.
This:

var c = new can.Compute(1)

would never work, if you wanted to be able to execute c directly to grab its current value, e.g. var val = c().

@alexisabril

This comment has been minimized.

Show comment
Hide comment
@alexisabril

alexisabril Oct 23, 2014

Contributor

@rjgotten Correct, there's an API change for can.Compute. You'll have to do:

c.get();

That being said, we are staying backwards compatible with can.compute(), however internally it will now create a new can.Compute() instance. Then when you do:

c(); //this will reference the internal new can.Compute and call get() respectively.
Contributor

alexisabril commented Oct 23, 2014

@rjgotten Correct, there's an API change for can.Compute. You'll have to do:

c.get();

That being said, we are staying backwards compatible with can.compute(), however internally it will now create a new can.Compute() instance. Then when you do:

c(); //this will reference the internal new can.Compute and call get() respectively.
@alexisabril

This comment has been minimized.

Show comment
Hide comment
@alexisabril

alexisabril Oct 23, 2014

Contributor

Noting current working branch for this feature: https://github.com/bitovi/canjs/tree/1255-compute/compute

Contributor

alexisabril commented Oct 23, 2014

Noting current working branch for this feature: https://github.com/bitovi/canjs/tree/1255-compute/compute

@daffl daffl modified the milestones: 2.3.0, 2.2.0 Jan 10, 2015

@daffl

This comment has been minimized.

Show comment
Hide comment
@daffl

daffl Oct 22, 2015

Contributor

Also merged and included in 2.3.

Contributor

daffl commented Oct 22, 2015

Also merged and included in 2.3.

@daffl daffl closed this Oct 22, 2015

@pYr0x

This comment has been minimized.

Show comment
Hide comment
@pYr0x

pYr0x Oct 22, 2015

sorry... cant find this feature in repo

pYr0x commented Oct 22, 2015

sorry... cant find this feature in repo

@daffl

This comment has been minimized.

Show comment
Hide comment
@daffl

daffl Oct 22, 2015

Contributor

In minor (and the 2.3 I'm just wrapping up) you can find it here: https://github.com/bitovi/canjs/blob/master/compute/proto_compute.js and as can.Compute.

Contributor

daffl commented Oct 22, 2015

In minor (and the 2.3 I'm just wrapping up) you can find it here: https://github.com/bitovi/canjs/blob/master/compute/proto_compute.js and as can.Compute.

@justinbmeyer

This comment has been minimized.

Show comment
Hide comment
@justinbmeyer

justinbmeyer Oct 22, 2015

Contributor

@pYr0x it's not documented. I'm not sure if it will be. Currently it's for internal use only. It's a bit faster then can.compute, but not enough to make it worth it for everyone to use.

Contributor

justinbmeyer commented Oct 22, 2015

@pYr0x it's not documented. I'm not sure if it will be. Currently it's for internal use only. It's a bit faster then can.compute, but not enough to make it worth it for everyone to use.

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