-
Notifications
You must be signed in to change notification settings - Fork 49
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was quite a pleasure to read over! All the pieces really are seriously coming together here...
I do think we gotta put some elbow grease into creating nodes before this super-awesome, but I'll settle for just awesome for now
@@ -41,12 +41,14 @@ features = [ | |||
] | |||
|
|||
[profile.release] | |||
# Tell `rustc` to optimize for small code size. | |||
incremental = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
examples/todomvc/Cargo.toml
Outdated
optional = true | ||
version = "0.4.6" | ||
|
||
[dependencies.serde] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might recommend collapsing these using inline tables where possible (as it's a bit more idiomatic I think)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated my cargo update
but it still is canonicalizing everything like this :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I don't think they're using something which preserves formatting (not sure if that exists in a production-ready capacity even...)
examples/todomvc/Cargo.toml
Outdated
|
||
[dependencies.log] | ||
optional = true | ||
version = "0.4.6" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might be able to expose some features of this to compile out debug!
and/or info!
statements perhaps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This crate itself doesn't do any logging, just dodrio
but it does need to depend on log
to get the Level
when initializing the console_log
logger. So I think it is OK to tie them together in the logging
feature since they are only ever used together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh for sure, but debug!
's code is emitted by default, which means there's a runtime check and the code for formatting is all compiled in. For the tiniest binaries we probably want to compile out the log messages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been seeing some debug!
s get compiled away when there is no logger -- should double check that for dodrio
for sure though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh right that's a good point. I think LTO is good enough to see that if no one sets the max log level the max log level is a constant that forbids logging so everything is optimized away as if it were already compiled out
examples/todomvc/index.html
Outdated
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>dodrio • TodoMVC</title> | ||
<link rel="stylesheet" href="node_modules/todomvc-common/base.css"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there perhaps an NPM CDN thing we could use to skip the npm install
step for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call: https://unpkg.com/
examples/todomvc/src/controller.rs
Outdated
|
||
/// Invoke `f` with the root `Todos` component, save the (likely just modified) | ||
/// todos to local storage, and schedule a new `dodrio` render. | ||
fn with_todos<F>(root: &mut dyn RootRender, vdom: VdomWeak, f: F) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using RAII may make this a bit more ergonomic to call by skipping some indentation maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not more ergonomic to write initially though
examples/todomvc/src/router.rs
Outdated
/// Start the router. | ||
pub fn start(vdom: VdomWeak) { | ||
// Callback fired whenever the URL's hash fragment changes. Keeps the root | ||
// TODOs collection's visibility in sync with the `#` fragment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now this is tricky
It's a comment that starts with "TODO"
not a TODO comment
// Call it once to handle the initial `#` fragment. | ||
on_hash_change(); | ||
|
||
// Now listen for hash changes forever. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps a small comment could be added about how this technically isn't linking memory within the context of this one application?
} | ||
|
||
/// Get this TODO's title. | ||
pub fn title(&self) -> &str { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I smell a derive macro for stuff like this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or just make it all pub
... a real application would probably not use pub
so I didn't here either. This is kind of an in-between scenario.
let title = self.edits.as_ref().unwrap_or(&self.title); | ||
let elem_id = bumpalo::format!(in bump, "todo-{}", id); | ||
|
||
let mut input_attrs = bumpalo::vec![ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just gotta say. This, ergonomically, is pretty awesome
} | ||
let input_attrs = input_attrs.into_bump_slice(); | ||
|
||
Node::element( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh we should definitely clean this up a bit at some point :)
(the helper methods you were mentioning would be perfect)
(well, that plus maybe a builder to add attributes)
Also I demand validation-via-travis. And I request publication-via-travis. |
We can skip an `npm install` now.
Instead of a `with<F>`-style function. It is a bit more idiomatic, and provides nicer usage, but takes a little more to write.
So they don't look like things we need to fix...
@alexcrichton want to take a look at the TodoMVC implementation?
If you're interested in some lolsob, also check out 5837d53...