Giter Site home page Giter Site logo

Comments (5)

nsndeck avatar nsndeck commented on May 22, 2024

I've tested your scenario and everything seems OK at least for nativescript-geolocation part. However @angular/http module need some more configuration in order to work. I've just added a call to subscribe method which triggers the http request.

 UserService.prototype.getCityDetails = function () {
        console.log('service call');
        var listCities$;
        this.http
            .get("" + this.baseUrl, { headers: this.getHeaders() })
            .map(mapPersons)
            .catch(handleError)
            .subscribe(function (r) {
            console.log("subscribe called with " + r);
            listCities$ = r;
        });
        console.dump(listCities$);
        return listCities$;
    };

Let me know how this works on your end.

from nativescript-geolocation.

MadhuSudhanBhaskar avatar MadhuSudhanBhaskar commented on May 22, 2024

Hi @nsndeck
Will try it and keep you posted!

Regards,
Madhu

from nativescript-geolocation.

MadhuSudhanBhaskar avatar MadhuSudhanBhaskar commented on May 22, 2024

@nsndeck I see data coming, but I can't return it back to the called function. I am using Typescript.

The outside console.dump(listCities$); before we return is still null.

var listCities$;
       this.http
         .get(`${this.baseUrl}`, {headers: this.getHeaders()})
         .map(mapPersons)
         .catch(handleError)
         .subscribe((r) => {
            listCities$ = r;
           //I get values here
          });
        //Here listCities is null
        console.dump(listCities$);
         return listCities$;

from nativescript-geolocation.

MadhuSudhanBhaskar avatar MadhuSudhanBhaskar commented on May 22, 2024

@nsndeck

    getCityDetails()  {
        console.log('service call');
        return Observable.create(observer => {
            var listCities$;
               this.http
                 .get(`${this.baseUrl}`, {headers: this.getHeaders()})
                 .map(mapPersons)
                 .catch(handleError)
                 .subscribe((r) => {
                    listCities$ = r;
                    observer.next(listCities$);
                    observer.complete();
                  });
        });
    }

This is for service

                this.userservice.getCityDetails().subscribe((r) => {

                    console.log('after service call');
                    this.myItems = r;
                    console.dump(this.myItems[0]);
                });
public myItems: RxObservable<Array<ListCities>>;
        <ListView [items]="myItems" class="list-group">
            <template let-item="item" let-i="index" let-odd="odd" let-even="even">
                <GridLayout class="list-group-item" [class.odd]="odd" [class.even]="even">
                    <Label [text]="item.name" ></Label>
                </GridLayout>
            </template>
        </ListView>

I can dump data, but not able to assign data to list view. Can you please help me here :)

from nativescript-geolocation.

nsndeck avatar nsndeck commented on May 22, 2024

Hi @MadhuSudhanBhaskar,

ListView cannot work with RxObservable's directly. You should use async pipe. Here is an example of using async pipe with nativescript-angular.

from nativescript-geolocation.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.