Skip to content

Instantly share code, notes, and snippets.

View astr0sl0th's full-sized avatar
💭
Rock'n'Roll 🤘🏻

Joe astr0sl0th

💭
Rock'n'Roll 🤘🏻
  • Function & Form
  • London
View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@astr0sl0th
astr0sl0th / syncData.js
Created July 22, 2023 15:12
Keep your Supabase data in sync with Algolia
const algoliasearch = require('algoliasearch');
const { createClient } = require('@supabase/supabase-js');
// Initialize Algolia client
const algoliaClient = algoliasearch('ALGOLIA_APP_ID', 'ALGOLIA_API_KEY');
const index = algoliaClient.initIndex('INDEX_NAME');
// Initialize Supabase client
const supabaseUrl = 'SUPABASE_URL';
const supabaseKey = 'SUPABASE_SERVICE_KEY';
import { Component, OnInit } from '@angular/core';
import { ModalService } from './modal.service';
@Component({
selector: 'app-notification',
templateUrl: './notification.component.html',
styleUrls: ['./notification.component.css']
})
export class NotificationComponent implements OnInit {
<app-modal
title="Notification"
subHeading="Success"
modalName="notification">
<p>Here is our notification, this could also be an @Input on the modal.</p>
</app-modal>
<div
class="modal"
[ngClass]="className"
[class.modal--open]="(toggleModal | async) === modalName"
>
<div class="modal__overlay" (click)="closeModal()"></div>
<div class="modal__container">
<div class="modal__body">
<button
class="close-button modal__close js-modal-close"
import { Component, OnInit, Input } from '@angular/core';
import { ModalService } from './modal/modal.service';
import { BehaviorSubject } from 'rxjs';
@Component({
selector: 'app-modal',
templateUrl: './modal.component.html',
styleUrls: ['./modal.component.css']
})
export class ModalComponent implements OnInit {
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class ModalService {
// Set inital state of modal to none
toggalModal: BehaviorSubject<string> = new BehaviorSubject('none');