Skip to content

Instantly share code, notes, and snippets.

View skantus's full-sized avatar
:electron:

Alejo Castaño skantus

:electron:
View GitHub Profile
@skantus
skantus / DelegatePatternExample.swift
Last active April 25, 2021 16:48
Explain to how the "Delegate Pattern" works using Playground LiveView in Swift
//: A UIKit based Playground for presenting user interface
// ---------------------------------- Imports -------------------------------- //
import UIKit
import PlaygroundSupport
// ---------------------------------- Model -------------------------------- //
struct ModelUI {
//
// SampleView.swift
// CounterApp
//
// Created by Alejo Castaño on 23/11/2019.
// Copyright © 2019 Facebook. All rights reserved.
//
import Foundation
import UIKit
// SampleView.swift
import Foundation
import UIKit
class SampleView: UIView {
var texto: String = "";
var label = UILabel(frame: CGRect(x: 0, y: 0, width: 200, height: 100))
@objc(setMessage:)
@skantus
skantus / DeviceModule.java
Last active November 26, 2018 08:08
A bridge sample of React Native using Third-Party Lib in Java Android
package com.device.rn
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.crashlytics.android.Crashlytics;
import io.fabric.sdk.android.Fabric;
@skantus
skantus / DevicePackage.java
Last active November 26, 2018 08:08
A bridge sample of React Native using Third-Party Lib in Java Android
package com.device.rn
import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
...
handleCallback = () => {
this.setState({ loading: true });
CalendarManager.ReqresEvent({ url: 'https://reqres.in/api/users?page=1' }, (response, error) => {
if (response) {
console.log(response.data);
} else {
console.log(error);
}
//
// HandleRestApi.m
// RNI
//
// Created by Alejo on 23/11/2018.
// Copyright © 2018 Facebook. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "HandleRestApi.h"
@skantus
skantus / Component.js
Last active November 24, 2018 13:36
Sending Events to JavaScript with RCTEventEmitter
...
import { NativeEventEmitter } from 'react-native';
const { CalendarManager } = NativeModules;
const calendarManagerEmitter = new NativeEventEmitter(CalendarManager);
class Home extends Component {
handleAddEvent = () => CalendarManager.addEvent('Birthday Party', { site: 'Barcelona Spain' });
handleEventListener = ({ enabled }) => {
@skantus
skantus / CalendarManager.h
Created November 24, 2018 12:52
Sending Events to JavaScript with RCTEventEmitter
//
// CalendarManager.h
// RNI
//
// Created by Alejo on 23/11/2018.
// Copyright © 2018 Facebook. All rights reserved.
//
#import <React/RCTBridgeModule.h>
#import <React/RCTEventEmitter.h>
@skantus
skantus / CalendarManager.m
Last active November 24, 2018 13:34
Sending Events to JavaScript with RCTEventEmitter
//
// CalendarManager.m
// RNI
//
// Created by Alejo on 23/11/2018.
// Copyright © 2018 Facebook. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "CalendarManager.h"