[SOLVED] Retrieve the properties of Object ?


Samuel Vanneste

Hello David and other pals,
Perhaps I am not seing it but, do we have a way to retrieve the properties of an unknown object ?

For example : in the case of using only one HttpClient for many Views, instead of adding the data values from inside each view, I do create an object. I have thought to submit that object to an AB function which would iterate each property and put it with its value as the HttpClient.
To be able to iterate, I add the properties in a separate array in the current View. And in the function, read each item and get its value from the Object.

This works great but is a bit long when using the same mechanism from the HttpClient.Response with an unkown Object (for ex: read an object property named "keys", split it by comma, iterate the array, get the property, get the value, get the property named "subkeys", split it, etc.).

Perhaps is there a better way to achieve this ? Many thanks

Edit: for example Object.GetProperties ?


DecSoft

Hello Samuel,

First of all, it's no problem to add as many HttpClient (and app's views) as you needed in an application, so, maybe it's a good idea to do not use the same HttpClient for different purposes, so we are more sure about how to deal with the specifics HttpClient possible responses, etc.

About exactly what you wanted, that is, iterate over an Object variable, maybe we can't do it using AB actions right now, but we always can use pure Javascript code or certain Javascript library like jQuery if we wanted to use it.

In pure Javascript we can do something like this:

Where "object" is our variable in this case. Look at this tutorial to know how we can access app's variables and other stuff from pure Javascript code. Please, post here any further question about this question.



Samuel Vanneste

Thank you David. I will try to apply that.

Please, don't take it bad, it is not an aggressive question but only a surprised one : which such projects you have previously described (20 views or more), you don't create some functions to reuse components ?
I am probably too object oriented now (reason why I'm often lost here crying) but isn't the fact to create each view as a "small" individual app, a "loss of time" ? You are more experienced than me, so I will try to apply that way to compare


DecSoft

Hello Samuel,

First of all, some sample code to try it:

About your last question... certainly we can reuse some functions and non visual controls across app's views, however, here in this thread you are talking about to reuse an HttpClient to perform various HTTP calls... ok, can be good... but my idea is that we have no limits in the number of HttpClients controls we can use, so, maybe it's a good idea to maintain it separated.

Of course, if the HTTP calls differs in a couple of arguments... maybe it's a good idea to simply reuse a control, however, I am thinking (that's the case of the application in which I am working now) that every HttpClient control have a very particular mission in the application: someone list certain data, others list other information, this list users, this other list articles, this other can be used to delete stuff, etc., etc.

Different tasks -> differents URLs (server's scripts) -> differents HttpClients controls. :)

However, continue talking about the application I am workin on right now, we reuse the same WebSocket control to maintain two different chats. In this case it's better to reuse the same control, which is placed in the first app's view and can be used in others too (since they are a non visual control).

Why we consider (may others can think different!) to reuse the WebSocket controls is fine? Because we maintain the connection in all the user's session, so we do this on one Websocket server and not two. On the other hand, the same WebSocket control's Message event is capable to differenciate the two available kind of chats. For this reasons we reuse this specific control.

But on the other hand we use lot of HttpClients controls... in different app's views... which produces differents results.



Samuel Vanneste

Fantastic App Builder :) Thanks David


DecSoft

Hello Samuel,

Glad to know you learn something more. Certainly it's a good think we can extend App Builder using pure Javascript. Our application's actions are finally translated into Javascript code, and, the compiler is prepared to accept Javascript code directly (with the StartJS and EndJS actions) so it's easy to mix App Builder's actions and Javascript code. You shown above a good example of that.


Everybody can read the DecSoft support forum for learning purposes, however only DecSoft customers can post new threads. Purchase one or more licenses of some DecSoft products in order to give this and other benefits.

This website uses some useful cookies to store your preferences.

I agree. Hide this note. Give me more information.