Git Product home page Git Product logo

Comments (2)

larscom avatar larscom commented on July 19, 2024 1

Hi, there is nothing wrong with the extension, its just how an extension works.

You have to add "storage" permission to the manifest.json

  "permissions": [
    "tabs",
    "storage"
  ]

After that it just works after clicking the button.

@Component({
  selector: 'app-popup',
  templateUrl: 'popup.component.html',
  styleUrls: ['popup.component.scss']
})
export class PopupComponent implements OnInit {
  message: string;

  constructor(@Inject(TAB_ID) readonly tabId: number) {}

  ngOnInit(): void {
    chrome.storage.local.set({ favoriteCocktail: 'Daiquiri' })
  }

  async onClick(): Promise<void> {
    this.message = await bindCallback<string>(chrome.storage.local.get.bind(chrome.storage.local, { favoriteCocktail: 'Daiquiri' }))()
      .pipe(map((result) => result['favoriteCocktail']))
      .toPromise();
  }
}

from ng-chrome-extension.

YhEtesian avatar YhEtesian commented on July 19, 2024

Hey Larscom,

I had added storage to the permissions already, but my problem was still happening. I have now switched over to the await code you posted and indeed it is working with that. I find it rather strange though that when passing the chrome storage directly as observable instead of making it a promise and awaiting it, it's not working.

I tried to cast the "sendMessage" example from the scaffold directly into an Observable (without .toPromise and await) and that seemed to work perfectly. But for some reason the storage callback doesn't like to be an Observable. Anyway my problem is solved so thanks for your help!

from ng-chrome-extension.

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.