Skip to content

Instantly share code, notes, and snippets.

View banujan6's full-sized avatar
🏠
Working from home

Banujan Balendrakumar banujan6

🏠
Working from home
View GitHub Profile
@banujan6
banujan6 / home.component.html
Created June 13, 2021 18:27
azure cognitive services + angular
<div class="container">
<div style="padding-bottom: 40px;" *ngIf="imageRawString !== null">
<div
class="object-marker"
*ngFor="let objectData of objects"
[ngStyle]="{
'margin-left.px': objectData.rectangle.x / image.ratio,
'margin-top.px': objectData.rectangle.y / image.ratio,
'width.px': objectData.rectangle.w / image.ratio,
'height.px': objectData.rectangle.h / image.ratio
@banujan6
banujan6 / medium-rxjs-observer.js
Last active September 4, 2021 17:06
Medium-RXjs-observer
// Simple Observer Object
const observer = {
next(data) {
console.log('We Received new data ' + data);
},
error(err) {
console.error('Oh, No. We got an error : ' + err);
},
complete() {
@banujan6
banujan6 / medium-rxjs-observable.js
Last active September 4, 2021 17:06
RxJs Medium Gists
import { Observable } from 'rxjs';
const observable = new Observable(subscriber => {
subscriber.next("First State / Data of Observable"); // Notifiying first state
subscriber.next("Second State / Data of Observable"); // Notifiying second state
subscriber.next("Third State / Data of Observable"); // Notifiying third state
// Just waiting 5 seconds
/**
First Example
**/
import { Observable } from 'rxjs';
// Observable Object
const observable = new Observable(subscriber => {
subscriber.next("First Message");
@banujan6
banujan6 / medium-rxjs-subjects.js
Created September 5, 2021 07:36
medium-rx-js-subjects
import { Subject } from 'rxjs';
const subject = new Subject();
subject.subscribe({
next: (v) => console.log(`observerA: ${v}`)
});
subject.subscribe({
next: (v) => console.log(`observerB: ${v}`)
});
@banujan6
banujan6 / medium-rxjs-subject-vs-observable.js
Last active September 5, 2021 08:00
medium-rxjs-subject-vs-observable
import { Subject, Observable } from 'rxjs';
const observable = new Observable(subscriber => {
subscriber.next(Math.random()); // passing a random number
})
// Gives 2 different number. Because Observables are unicast and it will be execute separatly for each subscription.
observable.subscribe(data => {
console.log('subscription a :', data); //subscription a :0.2859800202682865
@banujan6
banujan6 / medium-rxjs-operators-pipeable.js
Created September 5, 2021 08:59
medium-rxjs-operators-pipeable
import { Observable } from 'rxjs';
import { first } from 'rxjs/operators';
// Create a Observable which emits 2 values
const observable = new Observable(subscriber => {
subscriber.next('First Message');
subscriber.next('Second Message');
});
// "first()" is a pipeable operator that only returns the observable with the first value.
@banujan6
banujan6 / medium-rxjs-operators-creation.js
Last active September 5, 2021 09:37
medium-rxjs-operators-creation
import { of } from 'rxjs';
// of is a Creation Operator,
// That can create new Observable by taking the parameters as the emitting values.
of("First Data", "Second Data")
.subscribe(data => console.log(data));
// CONSOLE OUTPUT ------------------------
// > First Data
@banujan6
banujan6 / medium-rxjs-scheduler.js
Created September 5, 2021 10:10
medium-rxjs-scheduler
import { Observable, asyncScheduler } from 'rxjs';
import { observeOn } from 'rxjs/operators';
// "asyncScheduler" is a type of Scheduler which executes the Observable Asynchronously.
// "observeOn" is a Pipeable Operator that help us to re-emit the data with Scheduler.
const observable = new Observable((observer) => {
observer.next("First Data");
observer.next("Second Data");
observer.next("Third Data");