How to use the rxjs.from function in rxjs

To help you get started, we’ve selected a few rxjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github loomnetwork / dashboard / scripts / gen-tokens-info.ts View on Github external
import { concatMap, map, toArray, switchMap, mergeMap } from "rxjs/operators"

import Web3 from "web3"

import fs from "fs"
import { IAddressMapping } from "loom-js/dist/contracts/address-mapper"

const ERC20GatewayABI_v1 = require("loom-js/dist/mainnet-contracts/ERC20Gateway.json")

const envName = process.argv[2]

const envs = envName === undefined ?
    [production, dev, extDev] :
    [production, dev, extDev].filter((env) => env.name === envName)

from(envs)
    .pipe(concatMap(generate))
    .subscribe(
        (env) => console.log("done with " + env),
        console.error,
        () => console.log("done"),
    )

// =====================

interface Mapping {
    plasma: string,
    ethereum?: string,
    binance?: string
}

interface TokenInfo {
github deanius / rx-helper / demos / 02-speak-up.js View on Github external
const { interval, Observable, Subject, from } = require("rxjs")
const { flatMap, map, take, zip } = require("rxjs/operators")

const sayings = from(["International House of Pancakes", "Starbucks", "Dunkin"])

/*
    The flow of this demo is:
    - show a single spoken event
    - show sequentially processed overlapping events speak simultaneously
        (these are mode:sync handlers that kick off async processes)
    - discuss the implications of promisifying - argue you need
        a stream you can control instead
    - option A: If you had a promise for the handling, you could await it
*/
module.exports = ({ Agent, log, config }) => {
  const interactive = !!process.env.INTERACTIVE
  const infinite = !!process.env.INFINITE
  const { count = 2, concurrency = "parallel", tickInterval = 250 } = config
  // show elapsing of time in the log
  if (!interactive) {
github DSI-HUG / dejajs-components / projects / deja-js / component / mouse-dragdrop / mouse-dragdrop-cursor.component.ts View on Github external
constructor(elementRef: ElementRef, private dragDropService: DejaMouseDragDropService) {
        const element = elementRef.nativeElement as HTMLElement;

        observableFrom(this.position$).pipe(
            takeWhile(() => this.isAlive))
            .subscribe((pos) => {
                element.style.left = pos ? `${pos.left}px` : '-1000px';
                element.style.top = pos ? `${pos.top}px` : '-1000px';
            });

        const cursor$ = observableFrom(this.cursor$);

        // Hide
        cursor$.pipe(
            takeWhile(() => this.isAlive),
            filter((dragCursor) => !dragCursor),
            tap((dragCursor) => {
                if (this._currentCursor && this.contentElement && this.iconElement) {
                    this.contentElement.style.opacity = '0';
                    this.iconElement.style.opacity = '0';
                }
                this._currentCursor = dragCursor;
            }),
            delay(300))
            .subscribe(() => {
                this.position$.next(null);
                element.style.display = 'none';
github johandb / svg-drawing-tool / node_modules / @angular / router / esm2015 / src / utils / collection.js View on Github external
export function wrapIntoObservable(value) {
    if (isObservable(value)) {
        return value;
    }
    if (isPromise(value)) {
        // Use `Promise.resolve()` to wrap promise-like instances.
        // Required ie when a Resolver returns a AngularJS `$q` promise to correctly trigger the
        // change detection.
        return from(Promise.resolve(value));
    }
    return of(value);
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29sbGVjdGlvbi5qcyIsInNvdXJjZVJvb3QiOiIuLi8uLi8iLCJzb3VyY2VzIjpbInBhY2thZ2VzL3JvdXRlci9zcmMvdXRpbHMvY29sbGVjdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7OztBQVFBLE9BQU8sRUFBa0IsYUFBYSxJQUFJLFlBQVksRUFBRSxVQUFVLElBQUksU0FBUyxFQUFDLE1BQU0sZUFBZSxDQUFDO0FBQ3RHLE9BQU8sRUFBYSxJQUFJLEVBQUUsRUFBRSxFQUFFLE1BQU0sTUFBTSxDQUFDO0FBQzNDLE9BQU8sRUFBQyxTQUFTLEVBQUUsSUFBSSxJQUFJLFNBQVMsRUFBRSxHQUFHLEVBQUMsTUFBTSxnQkFBZ0IsQ0FBQztBQUVqRSxPQUFPLEVBQUMsY0FBYyxFQUFDLE1BQU0sV0FBVyxDQUFDOzs7Ozs7QUFFekMsTUFBTSxVQUFVLGtCQUFrQixDQUFDLENBQVEsRUFBRSxDQUFRO0lBQ25ELElBQUksQ0FBQyxDQUFDLE1BQU0sS0FBSyxDQ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2YgLmFwcGx5KG51bGwsIHdhaXRIZWFkLmNvbmNhdCh3YWl0VGFpbCkpLnBpcGUoY29uY2F0QWxsKCksIGxhc3RWYWx1ZSgpLCBtYXAoKCkgPT4gcmVzKSk7XG59XG5cbmV4cG9ydCBmdW5jdGlvbiB3cmFwSW50b09ic2VydmFibGU8VD4odmFsdWU6IFQgfCBOZ01vZHVsZUZhY3Rvcnk8VD58IFByb21pc2U8VD58IE9ic2VydmFibGU8VD4pIHtcbiAgaWYgKGlzT2JzZXJ2YWJsZSh2YWx1ZSkpIHtcbiAgICByZXR1cm4gdmFsdWU7XG4gIH1cblxuICBpZiAoaXNQcm9taXNlKHZhbHVlKSkge1xuICAgIC8vIFVzZSBgUHJvbWlzZS5yZXNvbHZlKClgIHRvIHdyYXAgcHJvbWlzZS1saWtlIGluc3RhbmNlcy5cbiAgICAvLyBSZXF1aXJlZCBpZSB3aGVuIGEgUmVzb2x2ZXIgcmV0dXJucyBhIEFuZ3VsYXJKUyBgJHFgIHByb21pc2UgdG8gY29ycmVjdGx5IHRyaWdnZXIgdGhlXG4gICAgLy8gY2hhbmdlIGRldGVjdGlvbi5cbiAgICByZXR1cm4gZnJvbShQcm9taXNlLnJlc29sdmUodmFsdWUpKTtcbiAgfVxuXG4gIHJldHVybiBvZiAodmFsdWUpO1xufVxuIl19
github Alfresco / alfresco-ng2-components / lib / content-services / tag / services / tag.service.ts View on Github external
addTag(nodeId: string, tagName: string): Observable {
        const tagBody = new TagBody();
        tagBody.tag = tagName;

        const observableAdd = from(this.apiService.getInstance().core.tagsApi.addTag(nodeId, tagBody));

        observableAdd.subscribe((tagEntry: TagEntry) => {
            this.refresh.emit(tagEntry);
        }, (err) => {
            this.handleError(err);
        });

        return observableAdd;
    }
github nemtech / nem2-sdk-typescript-javascript / src / infrastructure / AccountHttp.ts View on Github external
public getAccountsInfo(addresses: Address[]): Observable {
        const accountIdsBody = {
            addresses: addresses.map((address) => address.plain()),
        };
        return observableFrom(
            this.accountRoutesApi.getAccountsInfo(accountIdsBody)).pipe(
                map(({body}) => body.map(this.toAccountInfo)),
                catchError((error) =>  throwError(this.errorHandling(error))),
        );
    }
github LedgerHQ / ledger-live-common / cli / src / commands.js View on Github external
(acc, t) =>
                  concat(
                    acc,
                    from(
                      defer(() => {
                        const bridge = getAccountBridge(account);
                        return bridge.signAndBroadcast(account, t, "").pipe(
                          ...(opts["ignore-errors"]
                            ? [
                                catchError(e => {
                                  return of({
                                    type: "error",
                                    error: e,
                                    transaction: t
                                  });
                                })
                              ]
                            : [])
                        );
                      })
github SuperblocksHQ / ethereum-studio / packages / editor / src / services / wallet.service.ts View on Github external
fetchBalance(endpoint: string, address: string): Observable {
        return from(new Promise((resolve, reject) => {
            const web3 = getWeb3(endpoint);
            web3.eth.getBalance(address, (err: any, res: any) => {
                if (err) {
                    reject(err);
                } else {
                    resolve(web3.fromWei(res.toNumber()));
                }
            });
        }));
    },
github DSI-HUG / dejajs-components / src / common / core / text-metrics / text-metrics.service.ts View on Github external
constructor() {
        observableFrom(this.element$).pipe(
            delay(1),
            first())
            .subscribe((element) => {
                const charSize = [];
                for (let i = 0; i < 255; i++) {
                    const c = String.fromCharCode(i);
                    charSize[i] = this.getTextWidth(c, element);
                }
                this.charSize$.next(charSize);
            });
    }
github Alfresco / alfresco-ng2-components / lib / process-services-cloud / src / lib / group / services / group-cloud.service.ts View on Github external
getGroupRoles(groupId: string): Observable {
        const url = this.buildRolesUrl(groupId);
        const httpMethod = 'GET', pathParams = {}, queryParams = {}, bodyParam = {}, headerParams = {},
            formParams = {}, contentTypes = ['application/json'], accepts = ['application/json'];

        return (from(this.apiService.getInstance().oauth2Auth.callCustomApi(
            url, httpMethod, pathParams, queryParams,
            headerParams, formParams, bodyParam,
            contentTypes, accepts, Object, null, null)
        )).pipe(
            catchError((err) => this.handleError(err))
        );
    }