How to automatically refresh feed when user makes a new post in React Native - getstream-io

We have a simple screen based on the React Native tutorial with the following FlatFeed and StatusUpdateForm inside a StreamApp
<FlatFeed notify={true} />
<StatusUpdateForm
feedGroup="timeline"
/>
We want to automatically refresh the FlatFeed when the user makes a new post using the StatusUpdateForm control

React Native does not subscribe to the Feed. Therefore all transactions are triggered client side. Therefore you will need to write custom logic that os triggered when a post is created. If you use your own client you can wait the response form add activity, and then trigger an event that navigates you back to the feed.
This is not as simple as it is on the web React version.

Related

How to make the home page of my app dynamic?

I have an app with backend written in node.js and app written in dart(flutter).
We tend to display feeds on the homepage. But the user doesn't see the latest feeds until a manual refresh is done.
How can I prevent this manual refresh.
Currently we have a rest api in place which is called on the refresh.
Will sending a socket event help or should I use gRPC server streaming.

Deploying azure bot on website with directline 3.0 on NODEjs

I am trying to host my web app on localhost. I am using directline 3.0 and I want to push the messages into a window using websockets. I don't want to embed the bot. I already have the GET and POST request so I can send and receive the conversation by running the javascript files with the bearer tokens and get back the conversation running by sending and receiving messages from the bot but I want this to take place on the localhost website on a chat based window without embedding.
How can I do this? How do I link the chat window of websockets to the GET and post files so i can send the messages in real time.
I would recommend you integrate Direct Line directly (no pun intended) into you project by using the BotFramework-DirectLineJS package. This package is built specifically for communicating with a bot without using WebChat as the UI component.
There is a v3 example that you can reference. The project splits between the DirectLineBot and the DirectLineClient. The DirectLineBot demonstrates a v3 bot. You'll need to update this folder to include your v4 bot. The DirectLineClient works the same with v3 or v4. So, as your client connects, generates a token, and begins sending activities, your v4 bot should pick these up and respond accordingly. Similarly, your client should pick up the bot's responses.
At this point, you need to update your client to display the activities as they are sent and received from the user / bot.
You might also consider looking over this unofficial "plain ui" sample from the WebChat dev. It uses React however it does not rely on WebChat as the UI component. I was able to spin it up in about 5 mins. It is purposefully stripped of any styling and simply posts activities to the page as text/json objects.
You could remove the input field and configure the page to accept inputs to render on the page. It might be a useful starting place and could fit well with the above DirectLineJS option.
If none of those options are agreeable, then you will need to use Axios, Fetch, or some similar package to make your GET, POST, etc., calls between your client and bot.
Hope of help!

Use socket.io in react and node js application

I am using reactjs and nodejs for my application. I am calling the api created in nodejs in my react js component. Let's suppose, I have a component User. And i am calling api in componentWillMount function to get a list of users. So when a new user is added by add user component, The change is not reflecting to list of users. So i need to use socket.io to make application real time, so that my list of users can get something is updated in database and its time to render the component again.
Is there anything regarding above?
You could use Socket.io for updating the users list. Another option is to use server-sent events (for more info on the differences between the two, see this answer).
If you choose to use Socket.io, you can emit an event from the client once a new user is added. Once the server receives that event, it broadcasts it to all other connected sockets (using socket.broadcast.emit). The sockets listen to the users-update event (an example for this can be found here), and once they receive it, the client should update the User component and rerender it.
If you choose to use SSE, check out this article.
If you want to apply data from response of api to rendered component, I recommend you will call api on componentDidMount.
It is the great way.
Of course, you can use socket.io

Emberjs model not fully loaded before afterModel being fired

I have an action that retrieves some data from the DB and then I wanted to check that the data it have received is correct before it continues on with authentication. I am using invite codes to allow people to log into a public site that is for private corporate use only. I am able to get the data just fine, but the aftermodel is firing before the request is completed. I am making a call to an azure mobile service and the call is still in pending (according to chrome) when the aftermodel is firing off. Seems like it hasn't received the data at that point.
What is the best method to get this verification working properly? Once it verifies it would then allow them to log in with an external provider.
Please, look at this discussion: Ember authentication best practices?
If you don't need an Auth engine, then you could implement "verifying data" in beforeModel hook. Why beforeModel? Because if data is not correct, then app should redirect user to another page, and beforeModel is made for this logic: http://emberjs.com/guides/routing/preventing-and-retrying-transitions/#toc_aborting-transitions-within-code-model-code-code-beforemodel-code-code-aftermodel-code

Detecting an html button click with node.js?

I'm quite new to node.js, so my apologies if this is a potentially stupid question. I'm aware that when a new page is requested, it triggers a data event, which node can then handle accordingly; on my current project though, I have an html button that triggers a few events, but does not redirect the page. Because of this, node isn't recognizing that this is occurring. Is there any way for me to detect this? Or even, as a workaround, is there any way to call one of my node functions from the javascript embedded in the web page?
Thanks~
you are mixing up two different things, the data event in node which you are talking of is triggered because a network connection is established when you point the browser to your website, data is received and sent from the client to the server and back.
this has nothing to do with clientside ui events, for example a click event on a button.
if you want node to recognize a click on your button you have to send something to the server, you can either use a form, issue an ajax request or use websockets.
for ajax requests with jquery : jquery $.ajax documentation
a popular websockets implementation for node.js is socket.io
If you want to call something in Node from the client side, you can use socket.io to transfer events to Node. Then catch those events, and return the correct data back to the client. Refer to the socket.io "How to Use".

Resources