-
Notifications
You must be signed in to change notification settings - Fork 142
Standing Challenges #140
Comments
About the third and the fourth... Are there some techniques about immutables with object oriented programming? We have a (static)
|
I had an idea for Rendering into modals, but haven't tried it If your components that want inject stuff into modals registered their modal content rendering functions at definition time, then they could set the content state of the modal-component to use their rendering function. Bad pseudo code: var SaveChangesComponent = function(){
app.modalController.register( 'save-changes', function(){ return h('.modal-content') } )
var channels = {
confirm: function(){ app.modalController.content.set('save-changes') }
}
} |
Components... Is set of channels the one for the whole app? Or can events be component-specific? |
@neonstalwart differentiates between channels and events. Both are component specific and don't bubble. |
typically for generic components (like a text input component) they either generate generic events (like i also use events for my application-level events (
so, i have events for both - some are for the whole app and some are component-specific and the component-specific ones trigger the ones for the whole app. @kuraga i don't know if i understand your question properly... no part of that line of code is a handler.
function parentComponent(options) {
var events = hg.input([ ... ]),
firstName = hg.value(options.firstName),
state = hg.struct({
events: events,
firstName: firstName,
// equivalent to: state.firstNameEditor.set(textInput({ value: state.firstName }))
firstNameEditor: textInput({ value: firstName })
}),
...
return state;
}) does that help at all? |
@neonstalwart thanks, very useful! But sorry my question/thought is different. Is here Acccording to this, So, channels' context is set by Correct? |
@kuraga are you talking about my example code or... |
@kumavis no. See links in the message. P.S. Originally it wasn't a FAQ, I wanted to talk about "good way to isolate parts of state when handling a channel event". But seems like we don't understand each other. Just re-read my last message, please... Thanks. |
the example is trivial so it's no surprise that it doesn't help answer the question. the general pattern would be that
right, again, trivial examples are misleading. think of that
this is the beauty of all of this... a simple pattern is applicable to a single component and to the whole application (which is really just another component). so, there is no rule that |
This is a key. Thanks very much! So, there were nothinng to discuss - it was my misunderstanding only. Feel free to clean up our messages. Thanks! |
Can we add routing to the list of standing challenges? Switch statements in views leads to lots of duplicated code... IMO component-based routing approaches like react-router avoid this problem. |
Why would you ever need to change the contents? If you need two different modal contents, render two modals and enable whichever of them is appropriate. |
its more about a deeper component (widgets list) interacting with a component higher in the DOM ( widgets deletion confirm modal ) Right now im thinking of a top-level modal controller that other components that need modals register with when they are defined. Having a single modal controller also guarantees you wont endup with two modals showing at once, overlapping. |
Something I've come to realise is related to #132. Mercury doesn't just have a problem dealing with non-DOM events, but also non-DOM rendering. For example, you could view notifications as a result of rendering your application state, but virtual-dom doesn't include notifications, so you have to manage them manually somehow. Similarly, network calls are a result of 'rendering' your application state to the network, and the events that come back from the network are analogous to DOM events.
Fair enough, but if that happens unintentionally you probably have a bug elsewhere you'd need to fix anyway. |
@eightyeight very insightful, hadnt thought of notifications / network requests as a sort of rendering |
I've been trying to attach audio to the page by rendering an I haven't decided how we'll solve this yet; probably just hang a listener on the app state that uses the Audio API directly, rather than rendering an audio tag. Not sure if this is enough of a problem to warrant thoughts about an entire non-DOM 'rendering' pipeline. |
Though it's a good idea I believe the Audio API exposes a subset of what an audio tag is capable of doing, so attaching a tag might be what you want to do regardless. I think having a direct listener on the state outside |
The audio API does enough for our purposes that I don't want to bother with the DOM. Side-note, |
Here are a few things we're still trying to figure out how to do best, in no particular order
Animations / CSSTransitionGroup
e.g. a removal animation that keeps a removed item in the dom long enough to animate out.
mostly solved
Not duplicating state serialization
With shared state passed down the hierarchy
you end up with duplicated serialization
Rendering into modals or other places
You can put a render function or vdom into state to hand it off to a modal component, but it doesnt serialize.
Formalized component interface
If we can set expectations of component interface, it will be easier to make reusable pieces for the community.
Non-DOM events
Triggering events on components that don't come from the DOM. see thread.
cc: @neonstalwart @Raynos
some chat logs
The text was updated successfully, but these errors were encountered: