shogun-button-react 6.9.8 → 6.9.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { ShogunCore } from "shogun-core";
|
|
3
|
-
import { Observable } from "rxjs";
|
|
4
3
|
import "../styles/index.css";
|
|
5
4
|
type ShogunContextType = {
|
|
6
5
|
core: ShogunCore | null;
|
|
@@ -11,7 +10,6 @@ type ShogunContextType = {
|
|
|
11
10
|
login: (method: string, ...args: any[]) => Promise<any>;
|
|
12
11
|
signUp: (method: string, ...args: any[]) => Promise<any>;
|
|
13
12
|
logout: () => void;
|
|
14
|
-
observe: <T>(path: string) => Observable<T>;
|
|
15
13
|
setProvider: (provider: any) => boolean;
|
|
16
14
|
hasPlugin: (name: string) => boolean;
|
|
17
15
|
getPlugin: <T>(name: string) => T | undefined;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, { useContext, useState, createContext, useEffect, useRef, } from "react";
|
|
2
|
-
import { Observable } from "rxjs";
|
|
3
2
|
import "../styles/index.css";
|
|
4
3
|
// Helper type to check if core is ShogunCore
|
|
5
4
|
function isShogunCore(core) {
|
|
@@ -17,7 +16,6 @@ const defaultShogunContext = {
|
|
|
17
16
|
login: async () => ({}),
|
|
18
17
|
signUp: async () => ({}),
|
|
19
18
|
logout: () => { },
|
|
20
|
-
observe: () => new Observable(),
|
|
21
19
|
setProvider: () => false,
|
|
22
20
|
hasPlugin: () => false,
|
|
23
21
|
getPlugin: () => undefined,
|
|
@@ -64,19 +62,6 @@ export function ShogunButtonProvider({ children, core, options, onLoginSuccess,
|
|
|
64
62
|
// Poiché il metodo 'on' non esiste su ShogunCore,
|
|
65
63
|
// gestiamo gli stati direttamente nei metodi di login/logout
|
|
66
64
|
}, [core]);
|
|
67
|
-
// RxJS observe method
|
|
68
|
-
const observe = React.useCallback((path) => {
|
|
69
|
-
var _a;
|
|
70
|
-
if (!core) {
|
|
71
|
-
return new Observable();
|
|
72
|
-
}
|
|
73
|
-
const rx = (core === null || core === void 0 ? void 0 : core.rx) || ((_a = core === null || core === void 0 ? void 0 : core.db) === null || _a === void 0 ? void 0 : _a.rx);
|
|
74
|
-
if (rx && typeof rx.observe === "function") {
|
|
75
|
-
const observable = rx.observe(path);
|
|
76
|
-
return observable;
|
|
77
|
-
}
|
|
78
|
-
return new Observable();
|
|
79
|
-
}, [core]);
|
|
80
65
|
// Unified login
|
|
81
66
|
const login = React.useCallback(async (method, ...args) => {
|
|
82
67
|
var _a, _b;
|
|
@@ -499,7 +484,6 @@ export function ShogunButtonProvider({ children, core, options, onLoginSuccess,
|
|
|
499
484
|
login,
|
|
500
485
|
signUp,
|
|
501
486
|
logout,
|
|
502
|
-
observe,
|
|
503
487
|
hasPlugin,
|
|
504
488
|
getPlugin,
|
|
505
489
|
exportGunPair,
|
|
@@ -560,7 +544,6 @@ export function ShogunButtonProvider({ children, core, options, onLoginSuccess,
|
|
|
560
544
|
login,
|
|
561
545
|
signUp,
|
|
562
546
|
logout,
|
|
563
|
-
observe,
|
|
564
547
|
hasPlugin,
|
|
565
548
|
getPlugin,
|
|
566
549
|
exportGunPair,
|