{"action":"created","issue":{"url":"https://api.github.com/repos/jdanyow/aurelia-async/issues/3","labels_url":"https://api.github.com/repos/jdanyow/aurelia-async/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/jdanyow/aurelia-async/issues/3/comments","events_url":"https://api.github.com/repos/jdanyow/aurelia-async/issues/3/events","html_url":"https://github.com/jdanyow/aurelia-async/issues/3","id":101498974,"number":3,"title":"[Discussion] Syntax is terrible","user":{"login":"jods4","id":3832820,"avatar_url":"https://avatars.githubusercontent.com/u/3832820?v=3","gravatar_id":"","url":"https://api.github.com/users/jods4","html_url":"https://github.com/jods4","followers_url":"https://api.github.com/users/jods4/followers","following_url":"https://api.github.com/users/jods4/following{/other_user}","gists_url":"https://api.github.com/users/jods4/gists{/gist_id}","starred_url":"https://api.github.com/users/jods4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jods4/subscriptions","organizations_url":"https://api.github.com/users/jods4/orgs","repos_url":"https://api.github.com/users/jods4/repos","events_url":"https://api.github.com/users/jods4/events{/privacy}","received_events_url":"https://api.github.com/users/jods4/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-08-17T20:02:30Z","updated_at":"2015-08-25T23:17:53Z","closed_at":null,"body":"This is something that Aurelia absolutely needs, but I think that the double dotted syntax is aweful. It conveys no meaning. And when I just want to use a Promised value I don't see why I should `.value` it.\r\n\r\nGiven the current work on binding behaviors, I think it would be more appropriate to implement this through a behavior: `value.bind=\"promisedName & async\"`.\r\n\r\nOther options could be handled in a similar fashion if it is wanted (say using `& async-value`, `& async-status` etc.).\r\n\r\nThat said, it doesn't compose well... What about: `value.bind=\"user.address.city & async\"`. What part of the path does async apply to? :frowning: \r\n\r\nGoing a little bit further, I almost think that this should be baked in into Aurelia. I mean: what use is it to bind a Promise? Other than wanting to display its value when it resolves? So doing `value.bind=\"user.firstName\"` could \"just work\". Of course, this special-cases one object (`Promise`), but it is a core platform object with very special meaning and purpose, so I think that's OK."},"comment":{"url":"https://api.github.com/repos/jdanyow/aurelia-async/issues/comments/134767972","html_url":"https://github.com/jdanyow/aurelia-async/issues/3#issuecomment-134767972","issue_url":"https://api.github.com/repos/jdanyow/aurelia-async/issues/3","id":134767972,"user":{"login":"jods4","id":3832820,"avatar_url":"https://avatars.githubusercontent.com/u/3832820?v=3","gravatar_id":"","url":"https://api.github.com/users/jods4","html_url":"https://github.com/jods4","followers_url":"https://api.github.com/users/jods4/followers","following_url":"https://api.github.com/users/jods4/following{/other_user}","gists_url":"https://api.github.com/users/jods4/gists{/gist_id}","starred_url":"https://api.github.com/users/jods4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jods4/subscriptions","organizations_url":"https://api.github.com/users/jods4/orgs","repos_url":"https://api.github.com/users/jods4/repos","events_url":"https://api.github.com/users/jods4/events{/privacy}","received_events_url":"https://api.github.com/users/jods4/received_events","type":"User","site_admin":false},"created_at":"2015-08-25T23:17:53Z","updated_at":"2015-08-25T23:17:53Z","body":"First off I'd like to say that I think this is not an easy design issue and I'm kind of thinking aloud here. That's why you may sometimes have the impression that I'm playing devil's advocate or changing my mind erratically.\r\n\r\nI agree that although async is _important_, it is not the _most common_ scenario and having to pay a perf price for checking whether each part of each bound path is a Promise is probably not a great idea. Being explicit also serves as documentation for other devs, and some clarity about what is going on is good.\r\n\r\nThe next question is: supported by Aurelia's binding DSL or a binding behavior? \r\nI currently prefer the behavior approach because:\r\n- The syntax needs to make some sense and I can't think of anything except maybe ES7 `await`. It's ok-ish but I don't think it looks too good should there be more than one promise in the chain: `<div textcontent.bind='(await (await user).address).street'>`. Let's assume this syntax anyway for the sake of discussion.\r\n- With this syntax, how could we bind the promise state? Something like: `<i class=loading if.bind='???user.address.street???'>`.\r\n- This is OK for Promise, but what about Observables (i.e. RX). There's clearly no definite syntax for them here. Should they be a behavior (but then why not Promises?). If we find a syntax and add them to the binding DSL, where do we stop? What's the next library that gets included -- why not?\r\n- This adds complexity to the core of Aurelia. If it is doable externally with a behavior, I think it's good to decouple as much as reasonably possible.\r\n\r\nAs is probably apparent, I'm currently leaning towards an external syntax with a binding behavior, maybe `<div textcontent.bind='user.address.street & async'>`.\r\n- In this context I prefer the keyword `async` to `await`, I think it's more expressive. Note that it is _also_ an ES7 keyword that qualifies a function, just like we are qualifying the binding here.\r\n- If that's technically doable, I think it's best that the behaviour modifies every part of the binding path. This keeps things very simple and covers cases where some parts are Promises and some are not. The behaviour means: \"OK I know some parts are Promises, just do the right thing for me please\", which is basically opt-in to the \"implcit async support\" that was deemed too costly and confusing.\r\nJust not sure if/how this could be done with current Aurelia design (a behaviour that can affect each part of the observed path individually)?\r\n\r\nTo be fair, let's answers the questions I raised for `await` above with `async` behavior:\r\n- Binding to the promise state? Maybe use the behavior parameters: we could pass `value` (default), `fulfilled`, `settled`, `pending`, `rejected`. The example above becomes then `<i class=loading if.bind='user.address & async:pending'>`.\r\n- What about observables and other frameworks? No reason that they could not create their own behaviours in a similar way, say `<li repeat.for='item in observable & rx'>`.\r\n\r\nWhat do you think?"}}