How does the Meteor.method Optimistic UI work? - meteor

Is this question duplicated maybe? I cannot find what I want from other answers.
My understands are
Methods runs twice. First on the client (this.isSimulation=true), next on the server.
The client has stub methods.
Questions are
How can the client has stub methods? The client has built with server/main.js? Or the server sends methods as strings?
The client stub method has same imports/scopes with server?
I've put some consone.log on a method. These are not printed on the client. Why?

You are right, it is a duplicate. All your answers are here: https://stackoverflow.com/a/30475494/7733460
Moreover, you can study further here: https://learn-meteor.netlify.app/
Specifically, go to Meteor/Core/4. RPC with Meteor Methods, chapter 7

Related

Is it possible to make Spring MVC not to send an answer back to the client?

I am working on a Stub of a microservice with which the Network Function under test communicates via a REST API. The stub is developed with Spring MVC (Spring Boot 2.5.0)
Under certain cirtumstances we need to provoke an absence of reply from the stub to the NF. And here is where the question comes: how to sneak into the Servlet to block the reply back to the client? If that is even possible.
I have been for a while googling but I haven't found anything being really of any use. Before digging more into the framework I am making the question in case someone has had to solve this problem before.
If it is, any hint that we can use to work on the solution would be appreciated.
Thanks!

Blazor WebAssembly - use SignalR or Controller actions for basic operations?

I normally develop with ASP.NET MVC, but I'm very new to Blazor. I'm creating a new site in Blazor WebAssembly. The very first thing I need to do is create a page with a simple form, that can create or update an item and send it to the server, to be saved in the DB. I can either send the object using SignalR, or use HttpClient to post it to a controller action. What's the best practice here in Blazor Wasm? I was tempted at first to just use SignalR all the time.
I've seen examples of using both, but very little to help decide which to use in what circumstances. This was about the most useful thing I could find but it doesn't answer the exact question and it's also not specific to Blazor.
The question is specifically about the simple create update operation, but other pros and cons of both would be very helpful. Is it as simple as "only use SignalR when clients need to listen for messages from the server, to avoid having too many open connections"?
Thanks a lot
Is it as simple as "only use SignalR when clients need to listen for messages from the server, to avoid having too many open connections"?
Yes, I think it is. CRUDL operations are transactional and asynchronous. Do a transaction, wait forever on the user, do another transaction,.... I would always do these through an API Get/Post.
The only time I would consider SignalR is where I'm passing object defined objects - such as a Dictionary<string, object>. They are a pain in controller API calls.

What is Concept of Idempotent in RestFul WebApi? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
can anybody explain what is Idempotent in RestFul WebApi and when use it?
The GET, PUT, and DELETE methods are said to be idempotent; that is, calling them over and over will produce the same result without any additional side effects. For example, the caller should be able to call the DELETE action
on a specific resource without receiving any errors and without harming the system. If the resource has already been deleted, the caller should not receive an error. The same applies to the PUT action. For a given unique resource
(identified by an element URI), submitting a PUT request should update the resource if it already exists. Or, if it doesn’t exist, the system should create the resource as submitted. In other words, calling PUT over and over produces
the same result without any additional side effects (i.e., the new task will exist in the system per the representation provided by the caller, whether the system had to create a new one or update an existing one).
The GET action is also said to be safe. Safe means that nothing in the system is changed at all, which is appropriate for HTTP calls that are meant to query the system for either a collection of resources or for a specific resource. It is important that the idempotency of the service’s GET, PUT, and DELETE operations remain consistent with the HTTP protocol standards. Thus, every effort should be made to ensure those three actions can be called over and
over without error.
Unlike the other three actions, POST is not considered to be idempotent. This is because POST is used to create a new instance of the identified resource type for every invocation of the method. Where calling PUT over and over will never result in more than one resource being created or updated, calling POST will result in new resource instances—one for each call. This is appropriate for cases where the system must generate the new resource’s identifier and return it in the response.
Source: ASP.NET Web API 2: Building a REST Service from Start to Finish

node.js asynchronous initialization issue

I am creating a node.js module which communicates with a program through XML-RPC. The API for this program changed recently after a certain version. For this reason, when a client is created (createClient) I want to ask the program its version (through XML-RPC) and base my API definitions on that.
The problem with this is that, because I do the above asynchronously, there exists a possibility that the work has not finished before the client is actually used. In other words:
var client = program.createClient();
client.doSomething();
doSomething() will fail because the API definitions have not been set, I imagine because HTTP XML-RPC response has not returned from the program.
What are some ways to remedy this? I want to be able to have a variable named client and work with that, as later I will be calling methods on it to get information (which will be returned via a callback).
Set it up this way:
program.createClient(function (client) {
client.doSomething()
})
Any time there is IO, it must be async. Another approach to this would be with a promise/future/coroutine type thing, but imo, just learning to love the callback is best :)

How can something like BOSH be implemented using Java Servlets

BOSH (Bidirectional-streams Over Synchronous HTTP) is a sneaky way of implementing 2-way client-server communication in situations where true server-push is not allowed, most obviously to let a server push data to a browser client without having to use client polling.
It works by the client sending a request to the server, and the server doesn't respond immediately... rather it remembers the request but only responds when it has some data to send. When this happens the client immediately sends another request so there is virtually always a 'stored request' sitting on the server ready to push data to the client.
At least, that's how I think it works!
Update:
My question is how you can do this using a Java EE stack i.e standard servlets. Is this possible using say Servlet 2.x (I'm a bit rusty so I don't know if you can decline to send a response or something) or only using extensions through a wrapper like Atmosphere?
Not an equivalent but Servlet 3.0 introduces an Asynchronous API. With or without Servlet 3.0, there is also Atmosphere.
See also
Servlet 3.0 Asynchronous API or Atmosphere? Easy decision!
Asynchronous HTTP and Comet architectures
Jean François Arcand blog (the author of Atmosphere)
I think this is what you might be looking for: http://blog.jwchat.org/jhb/
Maybe you are looking for something like comet, a kind of reverse AJAX in which the client initiates the connection, allowing the server to push data when it wants.
EDIT: I realize you are looking for solutions in Java and when we think of AJAX we immediately think of JavaScript, but the term has been tainted lately and it represents a concept more than a JavaScript solution. Comet is very much a concept like AJAX and can also be implemented in the programming language of your choice.

Resources