reducer not getting called after dispatch when using mock service worker - redux

reducer not getting called on dispatch in - redux + thunk + react testing library + MSW
all details in https://github.com/reduxjs/react-redux/issues/1975
after dispatch reducer should get called and i should be ale to assert the mocked data returned by mock service worker
simillar kind of issue
Redux store not being populated when mocking API call

Related

Can a saga has multiple timeout handlers

We have implemented a saga that has a timeout method and worked as expected. Later we wanted to add one more timeout method. So, I have added it to the same saga but the second timeout is not getting called. These two messages will be called at a time. Can we have two IHandlerTimeouts in a single saga?
public class SagaPolicy1 : Saga<SagaPolicyData>,
IAmStartedByMessages<OrderPlacedCommand>,
IHandleTimeouts<TimoutMsg1>,//timespan 20min
IHandleTimeouts<TimoutMsg2>
await RequestTimeout<TimoutMsg1>(context, TimeSpan.FromSeconds(1200));
await RequestTimeout<TimoutMsg2>(context, TimeSpan.FromSeconds(360));
The short answer is yes. The documentation explicitly calls it out. Remember that a timeout can be queued after its saga has been completed (using MarkAsComplete()). Because a timeout is tied to a specific saga instance, it will be ignored once the saga instance is completed.

Recieved firebase answer to Unity project but not to Pico Device

I have a unity project in which I send subscribe to firebase and receive a callback every time a field changes - which I need to process according to the status of the fields.
FirebaseDatabase.Net is installed in the project
Problem 1, although my subscription invokes the callback func nicely when I change fields in the firebase, then I then build it for apk and install it on VR Pico G24K, I receive no connection from the firebase.
Problem 2: When I attempt to Query the firebase when not inside the callback func, both unity and pico will stuck.
Query func
private async Task<Device> QuerySingleDeviceAsync(string serial)
{
return await _firebaseClient.Child(Fields.DEVICES_ROOT).Child(serial).OnceSingleAsync<Device>();
}
Can anyone here point on something I might be missing (package I need to install for VR usage, or alternative function of questioning the firebase outside the observe's callback so I can better debug the no-comm issue?

How do the rest of the modules access "Firebase" class, after we initialize using ```Firebase.initializeApp();``` in the entry point?

So my app is working, but I want to understand what does the initialization actually do?
and why do we have access to a "Firebase" class only after we initialize?
in other words:
How do the rest of the modules access "Firebase" class, after we initialize using Firebase.initializeApp(); in the entry point?
for reference, this is one approach of how we initialize:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp()
);
}
My question is, how is the returned value of the initialized app stored? so that I can access it from any module?
In your case (no application name provided), it initializes a new FirebaseAppPlatform for the default Firebase App and returns it as a Future<FirebaseAppPlatform>. This method should be called before any usage of FlutterFire plugins.
Thanks to that FirebaseApp instance, all the Firebase module can get access to the initialized Firebase Application. Example for Firestore: FirebaseFirestore.instance
Thanks to that initialization using await, you'll also get a synchronous getter for the currentUser.

Does pact support consumer contract tests when consumer api calls more than one provider api

All the examples I could find on PACT has one to one mapping of producer api to consumer api. In our case all of our consumer apis will call more than one producer apis.
We are using pact Jvm. Our consumer contract tests run against consumer service. Producer mocks are defined in independent functions with #Pact attribute and contract tests have #PactTestFor(pactMethod = attribute, here "pactmockmethodname" is the function name which has producer mock. This setup is working fine. Now, We got into a case where our consumer api has to call more than one producer api. I tried defining multiple pact mocks but was not able to hook them to test as #PactTestFor attribute takes only one pactMethod. What is the suggested approach for this case.
Answering my above question. Found that we can add multiple pact mocks with builder.
Example
Consumer api calls two producer methods /user/1 and /user/account/1 we can define pact mock as below.
#Pact(consumer = "CONSUMER")
fun getUser(builder: PactDslWithProvider): RequestResponsePact {
return builder
.uponReceiving("get user basic info request")
.path("/user/1")
....... // define response status code and body as required
.uponReceiving("get user account info request")
.path("/user/account/1")
...... // define response status code and body as required
.toPact()
}
Consumer contract test can be something as below
#Test
#PactTestFor(pactMethod = "getUser")
fun `should respond with user info`() {
// consumer api call
val result = restTemplate.getForEntity("/customers/1",String::class.java)
val expected = ... // have expected here
assertEquals(HttpStatus.OK, result.statusCode)
assertEquals(expected, result.body, false)
}

Xamarin.Forms - Android Activity with async OnCreate method

I'm running into the questions if it's a problem to mark FormsAppCompatActivity.OnCreate(Bundle bundle) as async? I have to fetch user-specific data from an AWS DynamoDB, and I need to retrieve the user from the Akavache cache before in order to query with the userId. Of course, I could also save the userId to the local settings or serialize the whole user object to be able to retrieve it synchronously.
I also don't expect performance issues during startup because the cache uses SQLite definitely exists. The only problem is that either I await Akavache's GetObject<T>(string key) and therefore, mark everything down to OnCreate as async, or I subscribe to the returned Observable and the following methods will try to query the user data without a valid userId, because the Observable hasn't returned yet.
Since you're using XF for development, the code LoadApplication(new App()); in OnCreate of MainActivity will hook the lifecycle event to App's lifecycle event in PCL.
You didn't post any code, I guess that you place your code for data fetch after LoadApplication(new App());, then as you said it didn't return yet, otherwise the behavior should be different.
I suggest you to call your task in the OnStart() of App in PCL and together use DependencyService to call into your async task for fetching data from PCL.

Resources