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

Fixes #148 - Extra arg on Kinto#collection to replace Collection#use. #149

Merged

Conversation

michielbdejong
Copy link
Contributor

No description provided.

michielbdejong pushed a commit to michielbdejong/kinto.js that referenced this pull request Sep 7, 2015
@michielbdejong michielbdejong changed the title Introduce to replace (breaking change), fix #148 Introduce Collection#configure to replace Collection#use (breaking change), fix #148 Sep 7, 2015
@michielbdejong
Copy link
Contributor Author

@n1k0 maybe you prefer:

coll.configure({
  transformers: {
    remote: [ myRemoteTransformer ]
  }
});

instead of:

coll.configure({
  remoteTransformers: [ myRemoteTransformer ]
});

@n1k0
Copy link
Contributor

n1k0 commented Sep 7, 2015

The second version is fine, the first is quite verbose and not much more explicit.

}
if (config.remoteTransformers instanceof Array) {
this._transformers.remote = config.remoteTransformers;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably raise instead of silently ignoring the passed value here.

@michielbdejong michielbdejong changed the title Introduce Collection#configure to replace Collection#use (breaking change), fix #148 Move Collection#use to optional second argument of Kinto#collection (breaking change), fix #148 Sep 8, 2015
@michielbdejong
Copy link
Contributor Author

I went for this._plugins in the end. Hope you like it! Let me know if test coverage is ok, as well.

r? @n1k0

@@ -412,7 +412,7 @@ Transformers are basically hooks for encoding and decoding records, which can wo

### Remote transformers

Remote transformers aim at encoding records before pushing them to the remote server, and decoding them back when pulling changes. Remote transformers are registered by calling the `Collection#use()` method, which accepts a `Kinto.transformers.RemoteTransformer`-derived object instance:
Remote transformers aim at encoding records before pushing them to the remote server, and decoding them back when pulling changes. Remote transformers are registered through the optional second argument of `Kinto#collection()`, which accepts `Kinto.transformers.RemoteTransformer`-derived object instances in its remoteTransformers array.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: remoteTransformers (backticks)

@n1k0
Copy link
Contributor

n1k0 commented Sep 8, 2015

This is shaping good, I like the way we explicitly declare the transformers we plan to use for a given collection as soon as we retrieve an instance of it; some small concerns with the tests which are deviating a little from the general adopted strategy. Hope my comments help here, though feel free to reach out for help if needed :)

Thanks a bunch!

@michielbdejong
Copy link
Contributor Author

Thanks for the detailed feedback, will improve the structure of the tests!

@michielbdejong
Copy link
Contributor Author

Coverage increased (+0.4%) to 100.0% \o/ :)

@michielbdejong
Copy link
Contributor Author

@n1k0 wrote:

Wow, super nice point. We should stop caching collection instances methinks.

OK, that would simplify the code further. I think most apps will cache their constructed collections anyway (at least the Sync app does).

@michielbdejong
Copy link
Contributor Author

r? @n1k0

@@ -412,7 +412,7 @@ Transformers are basically hooks for encoding and decoding records, which can wo

### Remote transformers

Remote transformers aim at encoding records before pushing them to the remote server, and decoding them back when pulling changes. Remote transformers are registered by calling the `Collection#use()` method, which accepts a `Kinto.transformers.RemoteTransformer`-derived object instance:
Remote transformers aim at encoding records before pushing them to the remote server, and decoding them back when pulling changes. Remote transformers are registered through the optional second argument of `Kinto#collection()`, which accepts `Kinto.transformers.RemoteTransformer`-derived object instances in its `remoteTransformers` array.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably add a first-level Plugins heading and describe their underlying concept.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scratch this comment; as per IRC discussion, options would be more consistent.

@n1k0
Copy link
Contributor

n1k0 commented Sep 14, 2015

@michielbdejong r=r+wc

@michielbdejong
Copy link
Contributor Author

Rebased and squashed.

@michielbdejong michielbdejong changed the title Move Collection#use to optional second argument of Kinto#collection (breaking change), fix #148 Fixes #148 - Extra arg on Kinto#collection to replace Collection#use. Sep 14, 2015
michielbdejong added a commit that referenced this pull request Sep 14, 2015
Fixes #148 - Extra arg on Kinto#collection to replace Collection#use.
@michielbdejong michielbdejong merged commit 2775503 into Kinto:master Sep 14, 2015
@michielbdejong
Copy link
Contributor Author

Thanks for all your help with this!!

@michielbdejong michielbdejong deleted the 148-collection-configure branch September 14, 2015 10:46
@n1k0 n1k0 mentioned this pull request Sep 29, 2015
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

Successfully merging this pull request may close these issues.

2 participants