This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'dart:math' as math; | |
| import 'package:flutter/material.dart'; | |
| import 'package:flutter/rendering.dart'; | |
| import 'package:flutter/gestures.dart'; | |
| const double kTwoPi = 2 * math.pi; | |
| class SectorConstraints extends Constraints { | |
| const SectorConstraints({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import unittest | |
| from pagination import Pagination | |
| class PaginationTest(unittest.TestCase): | |
| def test_start(self): | |
| p = Pagination(15, per_page=5, current_page=1) | |
| self.assertEqual(0, p.start) | |
| p.current_page = 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import unittest | |
| from pagination import Pagination | |
| class PaginationTest(unittest.TestCase): | |
| def test_start(self): | |
| p = Pagination(15, per_page=5, current_page=1) | |
| self.assertEqual(0, p.start) | |
| p.current_page = 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| This is free and unencumbered software released into the public domain. | |
| Anyone is free to copy, modify, publish, use, compile, sell, or | |
| distribute this software, either in source code form or as a compiled | |
| binary, for any purpose, commercial or non-commercial, and by any | |
| means. | |
| In jurisdictions that recognize copyright laws, the author or authors | |
| of this software dedicate any and all copyright interest in the | |
| software to the public domain. We make this dedication for the benefit |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // pubsub/Subscriber.js | |
| import { Component, cloneElement, Children } from "react"; | |
| import { publisher } from "."; | |
| class Subscriber extends Component { | |
| state = { data: null }; | |
| onMessage = msg => { | |
| this.setState({ data: msg.data }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // pubsub/subscribe.js | |
| import React from "react"; | |
| import { Subscriber } from "./Subscriber"; | |
| export const subscribe = (Comp, topic) => { | |
| return ( | |
| <Subscriber topic={topic}> | |
| <Comp /> | |
| </Subscriber> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // pubsub/publisher.js | |
| import EventEmitter from 'eventemitter3'; | |
| const eventEmitter = new EventEmitter(); | |
| const publisher = { | |
| subscribe: (event, fn) => eventEmitter.on(event, fn), | |
| unsubscribe: (event, fn) => eventEmitter.off(event, fn), | |
| send: (event, payload) => eventEmitter.emit(event, payload) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // components/MyComponent/index.js | |
| import React from "react"; | |
| import { subscribe } from "../../pubsub"; | |
| export const MyComponent = props => subscribe(({ topic, data }) => { | |
| return <span>{data + " | "} {props.passedDownByProvider}</span> | |
| }, props.topic); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // context/Provider.js | |
| import React, { Component } from "react"; | |
| import io from "socket.io-client"; | |
| import { Context } from "./"; | |
| import { publisher } from "../pubsub"; | |
| const { REACT_APP_SOCKET_PORT: SOCKET_PORT } = process.env; | |
| const SOCKET_HOST = window.location.hostname; |
NewerOlder