Could not use Observable.of in RxJs 6 and Angular 6












49















 import { Observable, of } from "rxjs";

// And if I try to return like this
return Observable.of(this.purposes);


I am getting an error stating, Property 'of' does not exist on type 'typeof Observable'










share|improve this question




















  • 19





    In v6 it'd be just return of(this.purposes).

    – cartant
    May 8 '18 at 0:39













  • @cartat thankyou

    – k harish
    May 8 '18 at 4:26






  • 3





    where is this documented? The typical line is "You pull in any operator you need from one spot, under 'rxjs/operators' " which is obviously different from creation, but it's not clear the static method has been replaced. This import knowledge being scattered across the galaxy like I'm looking for the Tox Uthat is just lost time.

    – Joe
    May 8 '18 at 18:06
















49















 import { Observable, of } from "rxjs";

// And if I try to return like this
return Observable.of(this.purposes);


I am getting an error stating, Property 'of' does not exist on type 'typeof Observable'










share|improve this question




















  • 19





    In v6 it'd be just return of(this.purposes).

    – cartant
    May 8 '18 at 0:39













  • @cartat thankyou

    – k harish
    May 8 '18 at 4:26






  • 3





    where is this documented? The typical line is "You pull in any operator you need from one spot, under 'rxjs/operators' " which is obviously different from creation, but it's not clear the static method has been replaced. This import knowledge being scattered across the galaxy like I'm looking for the Tox Uthat is just lost time.

    – Joe
    May 8 '18 at 18:06














49












49








49


9






 import { Observable, of } from "rxjs";

// And if I try to return like this
return Observable.of(this.purposes);


I am getting an error stating, Property 'of' does not exist on type 'typeof Observable'










share|improve this question
















 import { Observable, of } from "rxjs";

// And if I try to return like this
return Observable.of(this.purposes);


I am getting an error stating, Property 'of' does not exist on type 'typeof Observable'







angular rxjs6 angular-observable






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 27 '18 at 9:43









mruanova

1,89221431




1,89221431










asked May 7 '18 at 19:05









k harishk harish

4591418




4591418








  • 19





    In v6 it'd be just return of(this.purposes).

    – cartant
    May 8 '18 at 0:39













  • @cartat thankyou

    – k harish
    May 8 '18 at 4:26






  • 3





    where is this documented? The typical line is "You pull in any operator you need from one spot, under 'rxjs/operators' " which is obviously different from creation, but it's not clear the static method has been replaced. This import knowledge being scattered across the galaxy like I'm looking for the Tox Uthat is just lost time.

    – Joe
    May 8 '18 at 18:06














  • 19





    In v6 it'd be just return of(this.purposes).

    – cartant
    May 8 '18 at 0:39













  • @cartat thankyou

    – k harish
    May 8 '18 at 4:26






  • 3





    where is this documented? The typical line is "You pull in any operator you need from one spot, under 'rxjs/operators' " which is obviously different from creation, but it's not clear the static method has been replaced. This import knowledge being scattered across the galaxy like I'm looking for the Tox Uthat is just lost time.

    – Joe
    May 8 '18 at 18:06








19




19





In v6 it'd be just return of(this.purposes).

– cartant
May 8 '18 at 0:39







In v6 it'd be just return of(this.purposes).

– cartant
May 8 '18 at 0:39















@cartat thankyou

– k harish
May 8 '18 at 4:26





@cartat thankyou

– k harish
May 8 '18 at 4:26




3




3





where is this documented? The typical line is "You pull in any operator you need from one spot, under 'rxjs/operators' " which is obviously different from creation, but it's not clear the static method has been replaced. This import knowledge being scattered across the galaxy like I'm looking for the Tox Uthat is just lost time.

– Joe
May 8 '18 at 18:06





where is this documented? The typical line is "You pull in any operator you need from one spot, under 'rxjs/operators' " which is obviously different from creation, but it's not clear the static method has been replaced. This import knowledge being scattered across the galaxy like I'm looking for the Tox Uthat is just lost time.

– Joe
May 8 '18 at 18:06












2 Answers
2






active

oldest

votes


















85














Looks like cartant's comment is correct, the RxJS upgrade guide doesn't cover that method specifically but does say "Classes that operate on observables have been replaced by functions"



Which seems to mean all or most of those class methods like .of, .throw etc. have been replaced by a function



So instead of



import { Observable, of } from "rxjs";
Observable.of(this.purposes);


do



import { of } from "rxjs";
of(this.purposes);





share|improve this answer



















  • 5





    import { of } from 'rxjs/observable/of';

    – sabithpocker
    Jun 14 '18 at 14:23






  • 1





    What about reduce()?

    – Marinos An
    Jun 26 '18 at 18:58











  • reduce() has been moved to the operators so you can import it using import {reduce} from 'rxjs/operators';

    – tim545
    Jul 18 '18 at 1:09






  • 3





    This is such an awful change. These methods should be static methods on a class like they were before. Name collisions are much more likely now.

    – Trevor de Koekkoek
    Oct 12 '18 at 22:15











  • You can have an overview of changes academind.com/learn/javascript/rxjs-6-what-changed

    – Inês Gomes
    Feb 21 at 10:02



















3














rxjs 6



import { PreloadingStrategy, Route } from '@angular/router';
import { Observable, of } from 'rxjs';

export class SelectivePreloadingStrategy implements PreloadingStrategy {
preload(route: Route, load: Function): Observable<any> {
return route.data && route.data.preload === false ? of(null) : load();
}

}





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50220854%2fcould-not-use-observable-of-in-rxjs-6-and-angular-6%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    85














    Looks like cartant's comment is correct, the RxJS upgrade guide doesn't cover that method specifically but does say "Classes that operate on observables have been replaced by functions"



    Which seems to mean all or most of those class methods like .of, .throw etc. have been replaced by a function



    So instead of



    import { Observable, of } from "rxjs";
    Observable.of(this.purposes);


    do



    import { of } from "rxjs";
    of(this.purposes);





    share|improve this answer



















    • 5





      import { of } from 'rxjs/observable/of';

      – sabithpocker
      Jun 14 '18 at 14:23






    • 1





      What about reduce()?

      – Marinos An
      Jun 26 '18 at 18:58











    • reduce() has been moved to the operators so you can import it using import {reduce} from 'rxjs/operators';

      – tim545
      Jul 18 '18 at 1:09






    • 3





      This is such an awful change. These methods should be static methods on a class like they were before. Name collisions are much more likely now.

      – Trevor de Koekkoek
      Oct 12 '18 at 22:15











    • You can have an overview of changes academind.com/learn/javascript/rxjs-6-what-changed

      – Inês Gomes
      Feb 21 at 10:02
















    85














    Looks like cartant's comment is correct, the RxJS upgrade guide doesn't cover that method specifically but does say "Classes that operate on observables have been replaced by functions"



    Which seems to mean all or most of those class methods like .of, .throw etc. have been replaced by a function



    So instead of



    import { Observable, of } from "rxjs";
    Observable.of(this.purposes);


    do



    import { of } from "rxjs";
    of(this.purposes);





    share|improve this answer



















    • 5





      import { of } from 'rxjs/observable/of';

      – sabithpocker
      Jun 14 '18 at 14:23






    • 1





      What about reduce()?

      – Marinos An
      Jun 26 '18 at 18:58











    • reduce() has been moved to the operators so you can import it using import {reduce} from 'rxjs/operators';

      – tim545
      Jul 18 '18 at 1:09






    • 3





      This is such an awful change. These methods should be static methods on a class like they were before. Name collisions are much more likely now.

      – Trevor de Koekkoek
      Oct 12 '18 at 22:15











    • You can have an overview of changes academind.com/learn/javascript/rxjs-6-what-changed

      – Inês Gomes
      Feb 21 at 10:02














    85












    85








    85







    Looks like cartant's comment is correct, the RxJS upgrade guide doesn't cover that method specifically but does say "Classes that operate on observables have been replaced by functions"



    Which seems to mean all or most of those class methods like .of, .throw etc. have been replaced by a function



    So instead of



    import { Observable, of } from "rxjs";
    Observable.of(this.purposes);


    do



    import { of } from "rxjs";
    of(this.purposes);





    share|improve this answer













    Looks like cartant's comment is correct, the RxJS upgrade guide doesn't cover that method specifically but does say "Classes that operate on observables have been replaced by functions"



    Which seems to mean all or most of those class methods like .of, .throw etc. have been replaced by a function



    So instead of



    import { Observable, of } from "rxjs";
    Observable.of(this.purposes);


    do



    import { of } from "rxjs";
    of(this.purposes);






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered May 9 '18 at 4:36









    tim545tim545

    95165




    95165








    • 5





      import { of } from 'rxjs/observable/of';

      – sabithpocker
      Jun 14 '18 at 14:23






    • 1





      What about reduce()?

      – Marinos An
      Jun 26 '18 at 18:58











    • reduce() has been moved to the operators so you can import it using import {reduce} from 'rxjs/operators';

      – tim545
      Jul 18 '18 at 1:09






    • 3





      This is such an awful change. These methods should be static methods on a class like they were before. Name collisions are much more likely now.

      – Trevor de Koekkoek
      Oct 12 '18 at 22:15











    • You can have an overview of changes academind.com/learn/javascript/rxjs-6-what-changed

      – Inês Gomes
      Feb 21 at 10:02














    • 5





      import { of } from 'rxjs/observable/of';

      – sabithpocker
      Jun 14 '18 at 14:23






    • 1





      What about reduce()?

      – Marinos An
      Jun 26 '18 at 18:58











    • reduce() has been moved to the operators so you can import it using import {reduce} from 'rxjs/operators';

      – tim545
      Jul 18 '18 at 1:09






    • 3





      This is such an awful change. These methods should be static methods on a class like they were before. Name collisions are much more likely now.

      – Trevor de Koekkoek
      Oct 12 '18 at 22:15











    • You can have an overview of changes academind.com/learn/javascript/rxjs-6-what-changed

      – Inês Gomes
      Feb 21 at 10:02








    5




    5





    import { of } from 'rxjs/observable/of';

    – sabithpocker
    Jun 14 '18 at 14:23





    import { of } from 'rxjs/observable/of';

    – sabithpocker
    Jun 14 '18 at 14:23




    1




    1





    What about reduce()?

    – Marinos An
    Jun 26 '18 at 18:58





    What about reduce()?

    – Marinos An
    Jun 26 '18 at 18:58













    reduce() has been moved to the operators so you can import it using import {reduce} from 'rxjs/operators';

    – tim545
    Jul 18 '18 at 1:09





    reduce() has been moved to the operators so you can import it using import {reduce} from 'rxjs/operators';

    – tim545
    Jul 18 '18 at 1:09




    3




    3





    This is such an awful change. These methods should be static methods on a class like they were before. Name collisions are much more likely now.

    – Trevor de Koekkoek
    Oct 12 '18 at 22:15





    This is such an awful change. These methods should be static methods on a class like they were before. Name collisions are much more likely now.

    – Trevor de Koekkoek
    Oct 12 '18 at 22:15













    You can have an overview of changes academind.com/learn/javascript/rxjs-6-what-changed

    – Inês Gomes
    Feb 21 at 10:02





    You can have an overview of changes academind.com/learn/javascript/rxjs-6-what-changed

    – Inês Gomes
    Feb 21 at 10:02













    3














    rxjs 6



    import { PreloadingStrategy, Route } from '@angular/router';
    import { Observable, of } from 'rxjs';

    export class SelectivePreloadingStrategy implements PreloadingStrategy {
    preload(route: Route, load: Function): Observable<any> {
    return route.data && route.data.preload === false ? of(null) : load();
    }

    }





    share|improve this answer




























      3














      rxjs 6



      import { PreloadingStrategy, Route } from '@angular/router';
      import { Observable, of } from 'rxjs';

      export class SelectivePreloadingStrategy implements PreloadingStrategy {
      preload(route: Route, load: Function): Observable<any> {
      return route.data && route.data.preload === false ? of(null) : load();
      }

      }





      share|improve this answer


























        3












        3








        3







        rxjs 6



        import { PreloadingStrategy, Route } from '@angular/router';
        import { Observable, of } from 'rxjs';

        export class SelectivePreloadingStrategy implements PreloadingStrategy {
        preload(route: Route, load: Function): Observable<any> {
        return route.data && route.data.preload === false ? of(null) : load();
        }

        }





        share|improve this answer













        rxjs 6



        import { PreloadingStrategy, Route } from '@angular/router';
        import { Observable, of } from 'rxjs';

        export class SelectivePreloadingStrategy implements PreloadingStrategy {
        preload(route: Route, load: Function): Observable<any> {
        return route.data && route.data.preload === false ? of(null) : load();
        }

        }






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered May 24 '18 at 10:49









        Tiny KingTiny King

        412




        412






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50220854%2fcould-not-use-observable-of-in-rxjs-6-and-angular-6%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

            Calculate evaluation metrics using cross_val_predict sklearn

            Insert data from modal to MySQL (multiple modal on website)