Replies: 33 comments
-
|
I'm leaning towards also agreeing, but also changing the |
Beta Was this translation helpful? Give feedback.
-
|
In my opinion, there is no need for async qualifier. We are not using component as a function in a JavaScript/typescript file, we are using it like a Dom element. I also don't find it confusing, await keyword clearly indicates an async operation. |
Beta Was this translation helpful? Give feedback.
-
|
I was also thinking that So, what if we call it export component App() {
await {
<Test/>
} nowait {
<h1>{"loading..."}</h1>
} catch (e) {
<div>{'An error occurred! ' + e.message}</div>
}
}
async component Test() {
let x = await new Promise(r => setTimeout(r, 2000));
<h1>{"hi"}</h1>
}with await any: export component App() {
await any {
<Test/>
<OtherTest />
} nowait {
<h1>{"loading..."}</h1>
}
}As far as |
Beta Was this translation helpful? Give feedback.
-
|
and if we want to keep |
Beta Was this translation helpful? Give feedback.
-
|
I actually quite like the idea of |
Beta Was this translation helpful? Give feedback.
-
|
Or maybe: export component App() {
try async {
<Test/>
<OtherTest />
} await {
<h1>{"loading..."}</h1>
}
} |
Beta Was this translation helpful? Give feedback.
-
|
I guess I think For the second block, I think I'd prefer |
Beta Was this translation helpful? Give feedback.
-
|
Let's maybe go with: export component App() {
try await {
<Test/>
<OtherTest />
} pending {
<h1>{"loading..."}</h1>
}
}Sounds good? Any alternatives or objections? I guess the usage of |
Beta Was this translation helpful? Give feedback.
-
|
Gave it some thought. I'd like to suggest Reasoning:
edit: examples Alternatives considered: |
Beta Was this translation helpful? Give feedback.
-
Can you provide some code examples? |
Beta Was this translation helpful? Give feedback.
-
👍 sounds good to me. As far as Also, if I create functions inside components with It does add a tiny bit of extra effort but makes the code ultimately more readable and brings it more in line with JS convention. Perhaps, various tooling can also work better in this case.
@JakeIsMeh I'm not sure I'm fully following, could you provide some code examples? |
Beta Was this translation helpful? Give feedback.
-
It's not the strongest examples, but I think it should show the semantic flow quite well |
Beta Was this translation helpful? Give feedback.
-
So you don't want |
Beta Was this translation helpful? Give feedback.
-
|
|
Beta Was this translation helpful? Give feedback.
-
|
from your example, it would be technically incorrect because What I'm leaning towards from out discussions:
|
Beta Was this translation helpful? Give feedback.
-
|
Because the component keyword is objectively distinct I don’t think an await keyword is necessarily required on the basis that because it’s compiled, you don’t have to take on the overhead of an awaited function in the final source if awaits aren’t in the body, so perhaps it’s better implicit. With regards to try/await syntax, I’d lobby for implementing a pattern matching some/none monad style for that. |
Beta Was this translation helpful? Give feedback.
-
|
^ also you aren’t muddying the functionality of built ins for both of the above proposals. |
Beta Was this translation helpful? Give feedback.
-
|
An example might be like But maybe there’s a better way to express it while lacking polymorphic variant types. |
Beta Was this translation helpful? Give feedback.
-
|
I've been thinking it through, and it seems we should just leave it as is. It's so flexible and there are less concepts to learn, no need to prefix components with async. The frameworks just figures out if the components should be with await or without. We could rename Currently, having a fallback block doesn't mean that it will ever be rendered if let's say all components in the try block as synchronous. I think it's mostly a good thing, if let's say you ever change an async component into sync. And just generally less to worry about. Also, if someone marks component with
I wonder if it would be possible later to make async components appear with a somewhat different color for |
Beta Was this translation helpful? Give feedback.
-
|
Most of the comments are based on our prior knowledge of typescript and other frameworks. A component is not a Typescript function, and we are not writing TS in a .ripple file (.rpl should be allowed) I see it differently, In my view we are creating RippleScript or Ripple lang. A new Typescript like/compatible compiled language and we can only write it in ,ripple files even If we are not creating a component (A reuseable function with reactive variables). We can start from first principles. I view a component like a DOM element, A container that can hold other components/elements and provide specific functionality. We don't think in terms of async or non async about DOM elements so like typescript a function can be async in RippleScript and a component can run an async function but we should not use async keyword with a component. let the compiler do the magic. In Typescript we use await to execute an async function and try/catch for error handling. We can do the same in RippleScript there is no need to invent something new just add an optional fallback block to try/catch component Page() {
try {
const data = await getUsers()
<UserList {data} />
} fallback {
<Spinner />
} catch (e) {
<ShowError />
}
} Unlike other complicated and over engineered frameworks, simple and easy to understand. |
Beta Was this translation helpful? Give feedback.
-
|
Great discussion, guys! I like each suggestion more than the last (except Ken's 🫶). The |
Beta Was this translation helpful? Give feedback.
-
|
Strongly agreed that components don't need to be marked This is one of my favorite things about Solid 2.0's async model over React and Svelte, the fact that bringing async data doesn't require marking the entire component as async. It's one less thing for the developer to add to their mental model. As for the blocks, I kinda like The other alternative is that if you have a What about |
Beta Was this translation helpful? Give feedback.
-
|
i would stick with just one syntax, so it's easy to learn. so, just the whole enchilada:
down the road we can have a version of as far as catching, it should go up the tree to the next catch if the current try block didn't provide its own. for
|
Beta Was this translation helpful? Give feedback.
-
|
I'm still leaning towards My concern is explicitness. Yes, we can say 'the user should be aware of it', but when someone's debugging why a I don't think any of the options brought up here are wrong, but rather which is "right" depends on how explicit Ripple wants the user to be, and I think that Or maybe I'm not in the right mindset yet? |
Beta Was this translation helpful? Give feedback.
-
|
@JakeIsMeh i think my proposal accounts for these. I'll restate for clarity.
This way you can't opt in-to a suspense boundary without knowing, you have to add a With your proposal, what I am imagining is that I have an existing try catch block, I want to add a pending indicator there, I add the pending block without adding the |
Beta Was this translation helpful? Give feedback.
-
|
That's fair. I'm more agreeable to it in that case. Regarding |
Beta Was this translation helpful? Give feedback.
-
|
I'm going update the current |
Beta Was this translation helpful? Give feedback.
-
|
@JakeIsMeh if you have code folding then it shouldn't be a problem. This is very glance-able. try {...}
pending {...}
catch (err) {...} |
Beta Was this translation helpful? Give feedback.
-
|
I'd argue most frontend devs (which by extension are React devs) are used to the wording of Additionally I don't think that (by default) combining 2 concepts (awaiting and error catching) into 1 is a good choice. The first reason is that it's not intuitive and obvious. The second, arguably more important, reason is that I believe most apps have some kind of top-level error boundary instead of wrapping every suspense in its own error boundary. So I don't think that most apps will looks like this: |
Beta Was this translation helpful? Give feedback.
-
|
Resolved now, thanks for the feedback |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, async components are automatically detected by the compiler, through the presence of
awaitin the component body.This behaviour, while convenient, may be surprising to some. For example, one may treat the
componentas just a variant offunction, and thus assume that they still need to qualify their async component declaration withasync.Additionally, as of now, async components do not render unless they are within a try...async block, which as projects scale will make it harder to debug.
Luckily, we are a compiler, so we can easily just emit warnings as we parse, but what the default behaviour should be is still up in the air.
Beta Was this translation helpful? Give feedback.
All reactions