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

masseuse formatters #81

Open
Duder-onomy opened this issue Mar 4, 2014 · 1 comment
Open

masseuse formatters #81

Duder-onomy opened this issue Mar 4, 2014 · 1 comment

Comments

@Duder-onomy
Copy link
Contributor

It would be nice to have a masseuse formatter. There are times when rivets formatters are not adequate. The different between a masseuse formatter and a computed property is that the value is represented differently when being read vs being published.

the interface would look something like this:

someValue : new masseuse.Formatter(read(otherVal), publish(otherVal))

In the following example, the value would be lowercase when being read (in the UI) and uppercase when being published (sent to server)

from a masseuse view model:

inputValue : new masseuse.ProxyProperty('transaction', this.model), //this could be a proxy or a computed
displayedValue : new masseuse.Formatter(
    function(inputValue) {
        return otherValue.toLowerCase();
    },
    function(inputValue) {
        return otherValue.toUpperCase();
    });

OR,

The current proxy properties can accept optional 3rd and 4th parameters. These would be a read and publish funciton.

someValue : new masseuse.ProxyProperty('someOtherValue', model, read, write);

function read(someOtherValue) {
   return someOtherValue.toUpperCase();
}

function write(someOtherValue) {
    return someOtherValue.toLowerCase();
}

OR,

Make a computed from a proxy:

someValue : new masseuse.ProxyProperty('someOtherValue', model),
valueToDisplay : new masseuse.ComputedProperty(['someValue'], function(someValue) {
    return someValue.toLowerCase();
})
@pajtai
Copy link
Member

pajtai commented Mar 5, 2014

I like new masseuse.ProxyProperty('someOtherValue', model, read, write);

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

2 participants