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

Improve the Context API #17

Closed
jknack opened this issue Jun 27, 2012 · 0 comments
Closed

Improve the Context API #17

jknack opened this issue Jun 27, 2012 · 0 comments
Assignees

Comments

@jknack
Copy link
Owner

jknack commented Jun 27, 2012

Problem:

If a user want to extends the context-stack, it have to use the "wrap" method of ContextFactory

Root Context:

  Context context = ContextFactory.wrap(model);

Child Context:

  Context context = ContextFactory.wrap(model);
  Context child = ContextFactory.wrap(context, moreData);

This works but have two disadvantages:

  1. The semantic isn't enough "wrap" isn't a clear name
  2. The object attributes are bind to the "root", this is error-prone and the context will get lost.

Solution

The new API has more semantic and help to reduce errors

Root Context:

  Context root = Context.newContext(model);

Child Context:

  Context root = Context.newContext(model);
  Context child = Context.newContext(child, data);

Extended Context:

  Context root = Context.newContext(model)
     .combine("user", user)
     .combine(map)
     .build();
@ghost ghost assigned jknack Jun 27, 2012
jknack added a commit that referenced this issue Jun 29, 2012
jknack added a commit that referenced this issue Jun 29, 2012
jknack added a commit that referenced this issue Jun 29, 2012
Introduce a ValueResolver #22
@jknack jknack closed this as completed Jun 29, 2012
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