Skip to content

Instantly share code, notes, and snippets.

import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/interval';
import 'rxjs/add/operator/switchMap';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/mapTo';
// This observable is subscribed to and emits observables
Observable.interval(1000)
/**
* Explanation of the issue causing login to break. This was fixed by
* https://github.com/Mobiquity/TCP_Mobile/pull/514/files
*
* The functional change is that the `.mergeMap` and `.catch` are chained to the
* inner Observable returned to `.switchMap`. Nothing is chained to `.switchMap`
*
* Originally, `.catch` was chained to `.switchMap`. This causes the Observable
* to complete when `.catch` is reached. ngrx/effects will not resubscribe in
* this case which may actually be a bug on their end, although this would be
const Foo = function () {}
Foo.prototype.bar = "bar",
Foo.prototype.arrow = () => {
console.log(this.bar);
};
Foo.prototype.fn = function () {
console.log(this.bar);
};
Foo.prototype.handyArrow = function () {
process.nextTick(() => console.log(this.bar));
diff --git a/src/app/password/password.component.ts b/src/app/password/password.component.ts
index b430b39..d45eba9 100644
--- a/src/app/password/password.component.ts
+++ b/src/app/password/password.component.ts
@@ -1,5 +1,5 @@
-import { Component, ViewChild, Input, Output, forwardRef, EventEmitter } from '@angular/core';
-import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
+import { Component, ViewChild, Input, Output, EventEmitter } from '@angular/core';
+import { FormControl } from '@angular/forms';
diff --git a/src/app/password/password.component.ts b/src/app/password/password.component.ts
index b430b39..d45eba9 100644
--- a/src/app/password/password.component.ts
+++ b/src/app/password/password.component.ts
@@ -1,5 +1,5 @@
-import { Component, ViewChild, Input, Output, forwardRef, EventEmitter } from '@angular/core';
-import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
+import { Component, ViewChild, Input, Output, EventEmitter } from '@angular/core';
+import { FormControl } from '@angular/forms';
 
// Make an API asynchronous
// In this example, we mock an iOS Keychain class. All operations
// are async (I/O), so when we use this mock in our tests, we
// want the operations to act async even though it's not needed
// for the class to work
class KeychainMock {
store: [],
async get(key) {
return this.store[key] || null;
}
// as a test function callback
it('removes username', inject([Storage], async storage => {
await storage.set('username', 'test user');
await storage.clear();
expect(await storage.get('username').toBeNull();
}));
async storeAccountInfo(username, password) {
await storage.ready();
await storage.set('username', username);
const cleanup = [];
if ((await touchId.encrypt()).withFingerprint) {
const [, secureStorage] = await Promise.all([
storage.set('usingTouchId', true),
secureStorage = await secureStorageFactory.create(),
]);
await secureStorage.set('password', password);

https://medium.com/@ExplosionPills/rxjs-switch-switchmap-and-other-map-operations-e8ccdfb7e5a9 is more up-to-date.

Exploring RxJS still feels like a jungle to me. Even when I think I understand something, I find out that I actually don't understand it. In my quest to truly understand it, I end up learning quite a lot more about some other topics or operations than the one I was originally trying to understand. This is generally a positive thing, but it still feels like traveling deep into a jungle to me.

Just today I was trying to learn how to use ngrx/store with ngrx/effects to use http requests with an ngrx/store-backed app. This introduced me to the RxJS Observable switchMap operator that I was not familiar with. The main question I came up with -- the question that I usually have when

For a long time, I had my own blog at one place or another. For a while, it was just at explosion-pills.com, then I popped up ghost on a DigitalOcean droplet at blog.explosion-pills.com. Finally, explosionpills.com became available, and now blog.explosionpills.com redirects to this medium blog that you’re reading through CloudFlare.

Deciding to move to Medium

I personally know a couple of people who use Medium as a blogging platform, and of course I follow a lot of famous or semi-famous people who blog directly on Medium. It has functionality that I can't take the time to implement in blogging software that I manage myself even if I think I could theoretically do it. Here, readers have access to comments, highlighting, and of course a broad network of content creators.