Comments (4)
So I've just been adding features to Pecy as I've needed them for some sites that I'm working on or as other people have needed them.
So our event story is still a work in progress.
I'm curious about what you think would be ideal here?
Would something like generally work for you / feel correct?
let input = html! {
<input type="text", !oninput=|mouse_event: web_sys::MouseEvent| {
//...
},></input>
};
I think we might be able to do this pretty easily (emphasis on think.. I'm just going off the top of my head..)
Here's what I'm thinking:
Right now we store our events as wasm-bindgen Closure
's
This prevents us from being able to have different events with different arguments since we're clearly specifying Fn() -> ()
there.
If we instead stored Function
's we could have whatever signatures we wanted.
So instead of converting the callback into a Function
here
We'd convert it here, right before adding it to the VirtualNode
(using unchecked_into
instead of unchecked_ref
I think..?
percy/crates/virtual-dom-rs/src/html_macro.rs
Line 192 in d968875
Then Events
here
would probably change to store Function
instead of Closure
Curious about your thoughts here! If this implementation makes sense I've be more than happy to answer absolutely any questions / clarify any of the above.
Otherwise I've already set aside time 2 weeks from now to work on Percy's router and re-writing the html!
macro as a procedural macro so I could also address this at that time.
At any rate.. Thanks a lot for opening up this issue! Keep them coming! We definitely want to prioritize things that people need right now so this is great.
from percy.
Ok so I actually started taking a look at implementing this and it's slightly more complicated than I laid out.
I'll think a bit and get back to ya
from percy.
Ok I think the way to go here is to just add macro rules for each type of input
oninput
ontext
.. etc
There's a finite number that isn't very large. If someone needs a custom event listener they can use the old !myevent = || {}
syntax.
I'll get a unit test and implementation for this in a PR and tag you. Then we can use that as an example for adding new events over time as we need them!
from percy.
Alright the codes messy and a work in progress but I have a branch with a failing test case
Note that this test is a little off since I'm asserting for text that isn't even in the input event.. I'll fix this up..
I Should have time this weekend to get this working
Again.. code isn't cleaned up at all just sharing the progress
from percy.
Related Issues (20)
- How alive is this project? HOT 3
- Use request_animation_frame from rust instead of Global Js call for update view HOT 3
- Free hosting? HOT 5
- Sub-routes not working? HOT 1
- Bash files in examples to rust-script? HOT 5
- Curly braces for value interpolation HOT 1
- Implement Performance Metrics HOT 2
- Implement a Formatting Tool HOT 2
- Consider Pure JS Transpilation HOT 2
- FYI: branding/naming clash HOT 1
- Crate renames HOT 1
- Docs: Broken CSS HOT 1
- Broken tests in html-macro 0.7.0 and 0.7.1 HOT 4
- Building nojs-first applications (and some thoughts about an isomorphic data layer) HOT 1
- Free Hosting for Demos HOT 1
- Allow Support for multiple parameters in `JSX` syntax HOT 4
- Spaces removed when isomorphic app is hydrated HOT 3
- File referred to in documentation doesn't exist
- Fix parenthesized blocks in html macro
- Panic happened in /allocator/free_list.rs that `new_page == 0` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from percy.