#AngularJS Unit Testing With Jasmine
##Directives
###Testing a Directive That Uses ControllerAs
// Replace app.moduleName with the name of the module that you want to test
describe("app.moduleName", function () {
"use strict";
#AngularJS Unit Testing With Jasmine
##Directives
###Testing a Directive That Uses ControllerAs
// Replace app.moduleName with the name of the module that you want to test
describe("app.moduleName", function () {
"use strict";
(function () { | |
'use strict'; | |
function Auth($http, $rootScope, $q, url) { | |
var auth = {}; | |
auth._events = $rootScope.$new(); | |
auth._currentUser = {}; | |
auth.getCurrentUser = function () { | |
if (auth._currentUserPromise) { |
When I originally sought to tackle this problem I chose the easier recursive solution to solve it with. However, due to the fact that in JavaScript Proper Tail Calls (PTC) (correct me if I'm wrong) are not currently supported and it seems like there's little hope that they'll be one soon. If they were, the trade offs here might be different (I haven't really thought through that scenario yet). For more on that see TC39/#22 and the transcript of the TC30 discussion.
For those of you that don't know, if we had PTC the stack growth issue with recursion would not be a problem. Meaning our memory complexity for the stack would be constant.
Anyway, the recursive solution is obviously much much easier but limited by the stack - which is never a great thing. So, depending on the size of your inputs, it may simply fail entirely.
So, I decided to implement it i
{"lastUpload":"2020-01-27T12:30:45.167Z","extensionVersion":"v3.4.3"} |
import React, { | |
createRef, | |
useState, | |
useEffect, | |
useRef, | |
useCallback | |
} from 'react' | |
function useIntersectionObserver(onChange, options) { | |
const [observer, setObserver] = useState(null) |
This codemod is for fixing one of the deprecated features of styled-components in v4. Namely, number 7 mentioned here - https://www.styled-components.com/docs/faqs#what-do-i-need-to-do-to-migrate-to-v4.
Styled Components has deprecated the ability to pass in an object as an argument to the .attrs
function.
🚫
import styled from 'styled-components'
import React from 'react' | |
import useIsElementInView from './useIsElementInView' | |
export function Example() { | |
const { ref, isInView } = useIsElementInView() | |
return ( | |
<div ref={ref}> | |
{isInView ? 'It is in the view!' : 'Not in view (so you cant really even tell if it works I guess...)'} | |
</div> |
const TitleSubtitleCell => ({ title, subtitle }) => ( | |
<div> | |
<Title>{title}</Title> | |
<SubTitle>{subtitle}</SubTitle> | |
</div> | |
) | |
const columns = [{ | |
header: | |
width: 'grow', // A width props supports custom column sizing |
<Switch> | |
<Route path="/users" exact component={UsersView} /> | |
<Route path="/home" exact component={HomeView} /> | |
<Route path="/settings" exact component={SettingsView} /> | |
</Switch> | |
<Switch> | |
<Route path="/users" component={UsersList} /> | |
<Route path="/users/create" exact component={CreateUserView} /> | |
<Route path="/users/:id" exact component={EditUserView} /> |
import invariant from 'invariant' | |
import { matchPath } from 'react-router' | |
import { pathToRegexp, compile } from 'path-to-regexp' | |
import map from 'lodash/map' | |
import trim from 'lodash/trim' | |
import flow from 'lodash/flow' | |
import partialRight from 'lodash/partialRight' | |
import isString from 'lodash/isString' | |
import isEmpty from 'lodash/isEmpty' | |
import { createSymbol } from '../../utils' |