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

Error on combination of oneTime & signal binding behavior #176

Closed
genadis opened this issue Dec 27, 2015 · 8 comments
Closed

Error on combination of oneTime & signal binding behavior #176

genadis opened this issue Dec 27, 2015 · 8 comments

Comments

@genadis
Copy link

genadis commented Dec 27, 2015

When trying to use onTime with signal binding as follows:

<div>${date | fromNow & oneTime & signal:'my-date-signal'}</div>

an error is thrown:

Unhandled promise rejection Error: One-time bindings cannot be signaled

It is useful as explained in example in aurelia-binding-behaviors
"Value converter that uses the current time to convert a record's datetime to a "time ago" value: posted ${postDateTime | timeAgo}. The moment this binding expression is evaluated it will correctly result in posted a minute ago. As time passes, it will eventually become inaccurate..."

So we can use signal to reavaluate the postDateTime that doesn't change.

From my understanding the signal is complementary to the binding and doesn't replace it.
I find it many times useful to manually reevaluate, so oneTime & signal seems like natural solution.

Is there a reason they cannot work together?

Thanks

@EisenbergEffect
Copy link
Contributor

@jdanyow Isn't a signal automatically a one-time binding? How should this be handled.

@jdanyow
Copy link
Contributor

jdanyow commented Dec 30, 2015

The combination of signal + one-time was intentionally disabled:

the signal binding behavior is not applicable to one-time bindings. Currently there is no reason to not support one-time bindings but I'm afraid supporting one-time bindings will prevent us from further optimizing one-time binding scenarios.
#126 (comment)

Time to reconsider this limitation... binding perf refactoring is complete. It should be safe to remove this check and allow one-time + signal.

Thoughts?

@EisenbergEffect
Copy link
Contributor

Obviously, the fix is simple. You are the binding expert. It's your call.

@jdanyow
Copy link
Contributor

jdanyow commented Dec 30, 2015

Will add some tests and get this into the next release.

@EisenbergEffect
Copy link
Contributor

Beautiful :)

@jdanyow jdanyow closed this as completed in 24ce672 Jan 6, 2016
@genadis
Copy link
Author

genadis commented Jan 9, 2016

works like a charm, Thanks!

@genadis
Copy link
Author

genadis commented Jan 9, 2016

It worked for the above case, but not with repeat.for:

        <template repeat.for="item of items & oneTime & signal:'my-signal">
          <li>
            <compose view-model.bind="item"></compose>
          </li>
        </template>

The list get's rendered once, If I add an item to items array and invoke my-signal the repeat.for is not re rendered.

Should I open separate issue?

@jdanyow
Copy link
Contributor

jdanyow commented Jan 9, 2016

please do- the repeat custom attribute handles oneTime differently than regular bindings

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

3 participants