Add many console methods#55
Conversation
|
I also recognize that @deniskolodin is going to rewrite how services work. This was mostly just for Rust practice/obsession reasons. |
|
I'm considering the dependency injection implications of this... If we wanted to inject a different type of console service onto context, it would still have to return a |
Remove trace call from timer demo.
|
Hm... it looks pretty! 👍 Thank you! I've fixed this: warning: unused variable: `name`
--> src/services/console.rs:12:25
|
12 | pub fn count(&self, name: &str) { js! { console.count(); } }
| ^^^^
|
= note: #[warn(unused_variables)] on by default
= note: to avoid this warning, consider using `_name` insteadAnd I've removed |
|
With Rust you can add as many traits as you want. There are no conflicts in the future. |
|
Thanks for the catch! My bad. Agreed with I'm not sure what you mean with your second comment. I'm thinking of the testing story, in which we might want to swap out services with spies, mocks, or stubs. If we expect a specific Truth be told, I have no idea how dependency injection would work with Yew at all, or even Rust for that matter. It would be nice to have it available, though. When I think "services", I do think dependency injection. But I think to do that, we'd need to expose services as a kind of middleware that dynamically transforms |
* Added demo doctest. * Added github action. * Move `test.yml` into correct folder. * Add remaining code snippets. * Fixed a syntax error in `test.yml`
* Added demo doctest. * Added github action. * Move `test.yml` into correct folder. * Add remaining code snippets. * Fixed a syntax error in `test.yml`
* Added demo doctest. * Added github action. * Move `test.yml` into correct folder. * Add remaining code snippets. * Fixed a syntax error in `test.yml`
* Added demo doctest. * Added github action. * Move `test.yml` into correct folder. * Add remaining code snippets. * Fixed a syntax error in `test.yml`
* Added demo doctest. * Added github action. * Move `test.yml` into correct folder. * Add remaining code snippets. * Fixed a syntax error in `test.yml`
* Added demo doctest. * Added github action. * Move `test.yml` into correct folder. * Add remaining code snippets. * Fixed a syntax error in `test.yml`
* Added demo doctest. * Added github action. * Move `test.yml` into correct folder. * Add remaining code snippets. * Fixed a syntax error in `test.yml`
Addresses #44
Also refactored the way
ConsoleServiceworks. It now creates an instance ofConsole, which itself can do (almost) everything the JS console can do.I had to name some functions
{function}_namedor similar because Rust doesn't have function arity overloading, which I did not realize until today!I find this methodology to be a bit more ergonomic than the currently implemented one. Definitely willing to hear criticism, though. I'm very new to Rust. =)