Как включить заметку из класса - PullRequest
0 голосов
/ 14 июня 2019

Я импортировал из класса из rxjs, но это не эффективно.Поэтому .from в методе sendMosaic вызывает ошибку, но я не знаю решения.

Пока у меня есть код, подобный этому:

import { Component, OnInit } from '@angular/core';
import { Account, NEMLibrary, NetworkTypes, Address, AccountHttp, AccountOwnedAssetService, AssetHttp, AssetId, TransferTransaction, TimeWindow, EmptyMessage, TransactionHttp } from "nem-library";
import { Observable, from } from 'rxjs';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {

  ngOnInit() {
    // Initialize NEMLibrary for TEST_NET Network
    NEMLibrary.bootstrap(NetworkTypes.TEST_NET);
  }


  // Send mosaic
  sendMosaic = () => {
    const privateKey = "";
    const address = this.user.address;
    const amount = 1;
    const account = Account.createWithPrivateKey(privateKey);

    Observable
      .from([{ mosaic: new AssetId(this.admin.mosaic.nameSpace, this.admin.mosaic.name), quantity: amount }])
      .flatMap((_) => new AssetHttp().getAssetTransferableWithAbsoluteAmount(_.mosaic, _.quantity))
      .toArray()
      .map((mosaics) => TransferTransaction.createWithAssets(
        TimeWindow.createWithDeadline(),
        new Address(address),
        mosaics,
        EmptyMessage
      ))
      .map((transaction) => account.signTransaction(transaction))
      .flatMap((signedTransaction) => new TransactionHttp().announceTransaction(signedTransaction))
      .subscribe(
        (value) => {
          console.log("Success:" + value.message);
        },
        (err) => {
          console.log("Failed:" + err.toString());
        }
      );
  }
}

Ошибка выдается послекомпилировать.

"ERROR in src/app/app.component.ts(71,8): error TS2339: Property 'from' does not exist on type 'typeof Observable'."
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...