Calling msg from another.rs

on my lib.rs i have a grid … in the grid there are two sides on the left is a post and on the right is a get fetch
. the problem i have is when some one posts on the message does not show on the fetch side unless refreshed

the way the proejct is layed out is like this
lib.rs
post.rs
get.rs

the post.rs and get.rs display using a grid on lib.rs

BUT the problem is once some one posts on post.rs i want to some how send a message on the lib.rs to run the little update msg to fetch again.
if a user presses a button on the main page to fetch again it will display. currently the way the get is working is uses click on the menu to the form section and the post is on the left and on the right get is shown BUT when some one presses submit (post on site) it does not fetch again. This makes sense but i do not know how to run a fetch command on the lib.rs from post.rs

Example of sending & handling messages:

fn update(msg: Msg, mut model: &mut Model, orders: &mut impl Orders<Msg>) {
    match msg {
        Msg::SendMessage => {
            let message_to_send = model.new_message.take();
            // Fire request. Server returns 200 + message. 
            // Message is then wrapped in `Msg::MessageSent`.
            orders.perform_cmd(send_message(message_to_send));
        },
        Msg::MessageSent(message) => {
            model.messages.push(message); 
       }
    }
}

...
div![
    "Send message",
    ev(Ev::Click, |_| Msg::SendMessage)
]

Also examples server_integration, server_interaction and websocket can help.

when i send messages from another.rs to lib it works
but when i go from lib to another is when i fail
i do not know how to include lib.rs in the file like i would do

I recommend to not think in files but in functions. Also it’s hard to help without seeing minimal examples of your architecture,

 Msg::SendPoster => {
                    orders
                      .skip()
                      .perform_cmd(send_request(model.make_name.clone(), model.make_body.clone()));
                      
                }

this is the send from postter.rs

this is has a submit button

      Msg::SendPoster => {
            orders
              .skip()
              .perform_cmd(send_request(model.make_name.clone(), model.make_body.clone()));
              
        }

then on the lib.rs

                postter::view(&model.postter)
            .els()
            .map_msg(Msg::PosterReq),],
            ],

this has

    >     Msg::PosterReq(msg) => {
    >         postter::update(msg, &mut model.postter, &mut orders.proxy(Msg::PosterReq));
    >     }
    >     Msg::GetterReq(msg) => {
    >         getter::update(msg, &mut model.getter, &mut orders.proxy(Msg::GetterReq));
    >     }

this is the get and post the display is like this

        div![
        div![style!{
          St::GridColumn => "1 / 3";
          St::GridRow => "1 /6";
          
        },
        div![style!{St::Width => "100%";
        St::Height => "100%"},
        postter::view(&model.postter)
        .els()
        .map_msg(Msg::PosterReq),],
        ],
      ],
    ],
    div![ style!{
      St::GridColumn => "2 / 3";
      St::GridRow => "2 / 4";
      St::OverflowY => "auto";
      St::TextAlign => "justify";
      St::Height => "79vh";
      St::ScrollbarColor => "#800080 #152736";
    },

      div![
    getter::view(&model.getter)
        .els()
        .map_msg(Msg::GetterReq),],
    ],

as you can see a single page is calling postter.rs and getter.rs
so they are side by side in the lib by using a grid

the good news is that when a user presses the button to go the webpage… it will refresh and load new data which is awesome using this

simple_ev(Ev::Click, Msg::GetterReq(getter::Msg::SendGetter))

but the problem is when some one presses “the button submit (post)” on the postter.rs i cant get it to to do a get request and refresh the lib.rs same SendGetter msg because i want it to call it on lib.rs . from postter.rs. if i display this in poster.rs it works but the data is then below the fields.

One option is to use the same Msg everywhere.
Or you can pass message to the parent (aka lib.rs) - see https://github.com/seed-rs/seed/pull/372.

i have tried using the message in postter … the problem is were it is set to render is on the lib.rs but the message render is declared on the lib.rs. so when it triggers the get message… it is trying to render it in the post.rs instead of the lib.rs
all i really want is from post.rs when it is pressed it triggers the message on lib.rs instead of trying to do this on its self. or refreshes the pages . thanks foryour sample i will try work threw it. once i can get the link to take me to the repo

it is like the websocket example is what i am trying to do. were the user has sent a message to the server and now the screen refreshes to show his message.

Do not worry you can close this issue. i will use a simple bool. if bool == false display the form
else bool == true hide the form and display a message “thanks for the message”. at least this app will be finished. Thank for all your help. bool val can change with a simple_ev! Ev::Click on the post button (submit) at least this way it will stop spammers also! which is a pain in the… to deal with