Managing state changes caused by an API patch - node.js

I have a data table that is populated GUI -> API call -> node backend -> loop back -> mongo db. Just displaying data works fine using NGRX state management. I use a modal dialog to edit one of the fields, trigger a submit change action, call the relevant patch API and successfully update the relevant record(s).
In order to reflect this changed record in the GUI. I call the get API when the SUCCESSFUL_SUBMIT action comes. This works fine, but i think it's not the correct way to do things with NGRX and I worry that this will cause maintenance problems in the future.
So my question is, how do i reflect the changed state in the GUI. Please note that I do not wish to display the change in the GUI until i know that the DB patch was successful.
The image shows the table with the console log having just submitted a change to auto archive.

This seems fine to me, but:
if the POST object reflects the GET object and if the server doesn't modify properties, you could update your store without the extra GET
the POST response body could include the object to prevent the extra GET

Related

Node.js application not rendering mongoDB collection after model.find()

I'm experiencing an issue in my node application with accessing the contents of a mongoDB collection via mongoose.
this problem only ever happens the very first time my application makes a call to the database collection. what should occur when the user presses the submit button, is that the contents of the collection should be added dynamically to the DOM. However, this does not occur. but when I check the collection via the command line interface, the user submitted data is there, and then when I press the refresh button on the browser (which hits the same route the user was redirected to upon initially submitting the form) the data renders to the page like it should have the first time.
When I noticed this, i tried starting from scratch. I dropped my database, restarted my server, but this time, I used robo3t to create the db and the collection before I started my app and filled out the form data, and viola, when I submit my data and hit save, the information gets saved to the collection AND rendered the the page successfully the first time.
So i went and looked at the different Model methods provided by mongoose and thought maybe I just needed to add a function call to initialize the collection sometime before calling Model.find() but everything i'm looking at tells me that the collection is already (obviously) initialized when you call mongoose.model()
so i'm a little confused about what to do in order to make sure my data gets rendered to the webpage the first time the user submits information, rather than after refreshing.....i've been careful about awaiting all the async functionality but maybe I missed something?
the repo is here in the unlikely case someone wants to clone this and try to recreate the situation. Let me know if there is more information I can provide
https://github.com/Funkh0user/TripCheq-Travel-Assistant
Thank you.
I Solved it. I needed to rearrange some things such that the block of code responsible for doing some computations and then sending the result back to the application was in the callback for model.find()
Thanks!

Refresh data from oracle database on jsf page refresh in adf 12c

I am using jdeveloper 12c to build fusion web app with oracle 12c database.
My project is running fine in browser and also can be accessible on other system's browser via static IP.
When someone is accessing application in browser and enter some data in table, it saves in database but it doesn't reflects on my browser even after refreshing page until unless i rebuild my project.
How can i get data without rebuilding my project (I want to fetch all updated data through page refresh).
I don't want to create a method for this.
Browser page refresh doesn't call data querying. You need to call Execute on needed iterators. For instance you can start a taskflow with Execute method before showing user interface.
I am not sure but, use Execute of that particular VO after commiting the data.Before using Execute in java code you have to add Execute in page deinition or go to that particular table in page. use binding property under property inspector. create the binding as given #{backingBeanScope.popupBean.refresh} and call it in java as like this to refresh the data while saving in DB 'AdfFacesContext.getCurrentInstance().addPartialTarget(refresh);'
Only you need to add EXECUTE button from that specific table (of which you want to refresh data) operation in data control tab, and you can label it as REFRESH button.

Persisting and identifying data in nodejs without a database

I am new to node and back end so please excuse me if my question seems dumb.
My use scenario is as follows:
I have a simple UI that will make only one ajax call at a given time. I have a node js backend that will take this call, make a login call to a webservice and use the response data to make another get call. When the call is over I will make a logout call and delete the login response data.
Problem:
The problem is that being single threaded and async and having no database the logout call will invalidated the login data for all the calls coming afterwards or that are in progress. I need a way to persist and encapsulate the data for each call without blocking the IO for each request.
Solution:
The only thing that I thought so far was to save the login data into dynamic created variables (based on the UI caller ID) and delete those vars when the call is over. However this seems like a very error prone solution that might also cause memory leaks.
I do not want to persist the data into a database and could not figure other solution, can you please advise?

hood.ie with couchDB method to refresh pages with DB change

I've started using hood.ie to make a web app.
I wanted to ask is there a convenient way to refresh pages whenever data in the couch db changes?
Thanks.
If you have a function that renders your page, like render, you can do this
hoodie.store.on("change", render)
The "change" event will trigger every time something changes in your data, be it because you called on of the hoodie.store APIs, or because of a changed synced from remote

Can I capture JSON data already being sent with a userscript/Chrome extension?

I'm trying to write a userscript/Chrome extension to capture JSON data being sent while using a web service so that I can reformat it and display selected portion on page. Currently the JSON is sent as the application loads (as I've observed from watching traffic with Fiddler 2). Is my only option to request the JSON again or is capture possible? As I'm not providing a code example, a requested answer is even some guidance on what method / topic to research or if I'm barking up the wrong tree.
No easy way.
If it is for a specific site you might look into intercepting and overwriting part of a code which sends a request. For example if it is sent on a button click you can replace existing click handler with your own implementation.
You can also try to make a proxy for XMLHttpRequest. Not sure if this even possible, never seen a working example. You can look at some attempts here.
For all these tasks you probably would need to run your javascript code out of sandboxed content script to be able to access parent page variables, so you would need to inject <script> tag with your code right into the page from a content script:

Resources