You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 18, 2019. It is now read-only.
I hope this is the right place to ask for help. I'm currently trying to get started with CycleJS and cycle-onionify and have troubles getting my app to produce the right output. Currently it is a simple input field, on every enter a message object is created and should then be rendered in a list. With starting to split that into multiple, smaller components, I see no output of my message list anymore (only my input field). To be more specific: I can log the list of messages (which contain the correct amount of messages) and in my Message-component I also get a log output for the sources, so the code is at least touched (means: 2 messages in the list, 2 logs in my console; 3 when I add one more message and so on).
My Message-component looks like the following:
importxsfrom'xstream';import{div,p}from'@cycle/dom';importisolatefrom'@cycle/isolate';constcalculateTimeString=timestamp=>{constdate=timestamp&&newDate(timestamp);return`${date.toLocaleDateString()}: ${date.toLocaleTimeString()}`;};functionMessage(sources){conststate$=sources.onion.state$;console.log(state$);// --> logs a MemoryStreamconstvdom$=state$.map(state=>{// HELPME this does not produce any outputconsole.log('Message',state);returndiv('.messageItem',[p(calculateTimeString(state.time)),p(state.message),]);});return{DOM: vdom$,onion: xs.empty(),};}// (sources) => ...exportdefaultisolate(Message);
and is integrated into the following MessageList:
import{ul}from'@cycle/dom';importisolatefrom'@cycle/isolate';import{pick,mix}from'cycle-onionify';importxsfrom'xstream';importMessagefrom'./../Message';functionMessageList(sources){conststate$=sources.onion.state$;constchildrenSinks$=state$.map(messages=>{// --> with every new message, this logs me the array of messages [{...}, {...}, ...]console.log('MessageList',messages);returnmessages.map((msg,i)=>{returnisolate(Message,i)(sources);});});constvdom$=childrenSinks$.compose(pick(sinks=>sinks.DOM)).compose(mix(xs.combine)).map(ul);constreducer$=childrenSinks$.compose(pick(sinks=>sinks.onion)).compose(mix(xs.merge));return{DOM: vdom$,onion: reducer$,};}exportdefaultMessageList;
For the sake of completeness, everything is integrated into this main app:
importxsfrom'xstream';import{div,p,input}from'@cycle/dom';importisolatefrom'@cycle/isolate';import{prepend}from'ramda';// FIXME how to strcutre components? why not automatically importing index?importMessageListfrom'./components/MessageList/index';functionintent(domSource){returndomSource.select('.message').events('keydown').filter(({ keyCode, target })=>keyCode===13&&target.value!=='').map(ev=>{constval=ev.target.value;// eslint-disable-next-line no-param-reassignev.target.value='';return{time: Date.now(),message: val,};});}functionmodel(action$){constinitReducer$=xs.of(()=>({messages: []}));constupdateReducer$=action$.map(message=>prevState=>({messages: prepend(message,prevState.messages),}));returnxs.merge(initReducer$,updateReducer$);}exportdefaultfunctionApp(sources){constmessageListSinks=isolate(MessageList,'messages')(sources);constaction$=intent(sources.DOM);constparentReducer$=model(action$);constmessageListReducer$=messageListSinks.onion;constreducer$=xs.merge(parentReducer$,messageListReducer$);constvtree$=messageListSinks.DOM.map(listNode=>div([p('Eingabe einer neuen Nachricht:'),input('.message',{attrs: {type: 'text',autofocus: true}}),listNode,]));return{DOM: vtree$,onion: reducer$,};}
Am I missing something? Am I doing something wrong? I tried to stick to the example here in the repo, but cannot find my error.
Hope one of you can help me out, in case you need more infos or the whole source-code, please let me know!
The text was updated successfully, but these errors were encountered:
Hey,
I hope this is the right place to ask for help. I'm currently trying to get started with CycleJS and
cycle-onionify
and have troubles getting my app to produce the right output. Currently it is a simple input field, on every enter a message object is created and should then be rendered in a list. With starting to split that into multiple, smaller components, I see no output of my message list anymore (only my input field). To be more specific: I can log the list of messages (which contain the correct amount of messages) and in my Message-component I also get a log output for the sources, so the code is at least touched (means: 2 messages in the list, 2 logs in my console; 3 when I add one more message and so on).My Message-component looks like the following:
and is integrated into the following MessageList:
For the sake of completeness, everything is integrated into this main app:
Am I missing something? Am I doing something wrong? I tried to stick to the example here in the repo, but cannot find my error.
Hope one of you can help me out, in case you need more infos or the whole source-code, please let me know!
The text was updated successfully, but these errors were encountered: