How to fetch current state of a Wave? - google-wave

With the current Wave API, is there any way to fetch the current state of a Wave? I want to write a little notifier app that observes any changes in a certain wave and notifies me...

The wave server will send you an update whenever a wave changes, so this is the default. What it can't do is send you the "current" value because of the delta logic on which Wave is based. So you will get a stream of deltas until the Wave server can assume that your copy of the value is current.

Related

Accessing flink state within Window via queryable state or storing state after each window aggregation

I am using apache flink to aggregate kafka stream on certain amount of time based windows.
After window expires, data will be saved to storage and this is all implemented via this structure:
SingleOutputStreamOperator<Aggregator> stream = source
.forceNonParallel()
.keyBy(Object::getKey)
.window(TumblingEventTimeWindows.of(Time.minutes(5)))
.aggregate(new CustomAggregator(), new KeyedWindowFunction("m5"));
Now my requirement is to have access to window state at any point in time in order to retrieve it because I am showing realtime chart on UI.
So for example, in this case only after 5 mins have expired will object be saved to data storage and be eligibale for access and that means that users will only see last 5 minutes and not the current aggregation which is non ideal.
As far as I see there are 2 options:
Either flink exposes way to access window state via queryable state
Or I need to create custom state object and on each element after aggregation store this into the state object so I can retrieve it via queryable state.
ProcessWindowFunction has access to context and state, but its called only after window has expired which is no use to me since at that point, data will be put into sink.
Problem with second approach is that AggregateFunction called in .aggregate() does not have access to context and so I cannot save it there.
So the question is, is there a wat to combine: window, AggregateFunction, and be able to store each aggregation of wndow into custom state object?

After the GPS location has changed, how to retreive the new gps coordiantes?

Using the npm package azure-maps-control. After the user drags around in the map. I would like to upgrade the points of intrest using a API call. For this i found multiple events. It looks like that the sourcedata event can be used. Unfortunately after dragging i need the new GPS locations. How do i retrieve those?
For your scenario you will most likely want to wait until the user has stopped moving the map before making a request to a service to retrieve custom data since doing this while the map moves would potentially generate tens of requests per second. What you will want to do is monitor the moveend event of the map by doing something like map.events.add('moveend', yourCallbackFunction). When this event fires, you can then retrieve the center position of the map using map.getCamera().center. Here is a code sample from the Azure Maps team that does all of this and a bit more: https://azuremapscodesamples.azurewebsites.net/?sample=Load%20POIs%20as%20the%20map%20moves This sample makes multiple requests when the moveend event fires as the service it calls returns a max of a 100 results at a time, and this sample steps through and pulls in additional results.

React / Flux: Should I have stores listen to other stores for changes?

I've built out a basic flux app for my first real world implementation.
Say I have a basic currency conversion app.
When I change the amount, or the currency to/from dropdowns I need to make ajax calls to
- 1) refetch currency info, and
- 2) recalculate the conversion rates.
I have a rate store, and a currencyInfo store.
Here's my biggest hangup:
How do I tell the stores to refetch the data based on the various UI pieces / other store data changing?
These updates should happen in order as well, so
- 1) Update UI state
- 2) fetch Currency Info & update state / UI 3) fetch conversion, make calculation and update state / UI with final numbers.
Options I see:
a) (blech) ViewActionCreator.changeAmount(), changeFromCurrency(), changeToCurrency(), all API.fetchCurrency(), and then API.fetchConversion() and hope the ajax calls come back in the right order or try to figure out waitFor
b) Have the conversionStore and currencyStore listen to changes to the amountStore and then refetch their own data
c) ?
I suggest you check out the waitFor() method in the flux dispatcher. It allows you to specify the order in which stores update in response to actions.
Facebook's chat app has a good example of this, where one store waits for two other stores to finish updating before it updates in response to an action.
https://github.com/facebook/flux/blob/master/examples/flux-chat/js/stores/UnreadThreadStore.js

ReactJS - props vs state + Store designing

Imagine the following:
you're writing a 'smart-house' application which manages a temperature in your house.
In my view I'd like to:
see current temperature for each room
set desired temperature for each room
see whether air conditioning is turned on/off for each room
There is an external device, communicating with your aplication via websockets (it is periodically sending current temperature, air conditioning status).
I see two options there:
1) Create one 'big' store containging data structures like:
var _data = [
name: 'Kitchen',
currentTemperature: 25,
desiredTemperature: 22,
sensors: [
{
name: 'Air Conditioning'
state: 'on'
}
... there might be other sensors too ...
]
]
There will be a TemperatureManager component (or something similar). It would have a state and fetch it from Store periodically.
Then it would just distribute part of the state to his descendants (ie RoomTemperatureManager, RoomSystemSensorManager), passing it as props.
If anything changes (for example, temperature in the bedroom), it will fetch all data from store and re-render its descendants if necessary.
2) The second solution is
to make RoomTemperatureManagers and RoomSystemSensorManagers have their own state. It is also related to having standalone stores for both Temperature and SystemSensorState.
Those Stores would then have parametrized getters (ie getSensorState(roomName)) instead of methods to fetch all data.
Question:
Which option is better?
Additional question:
Is it okay for leaf components (ie the one responsible for managing desired temperature) to call ActionCreator directly? Or maybe only the Supervising Component should know anything about ActionCreator and should pass proper method as a property to his descendants?
The 2 options you describe in your post are really 2 diffent questions:
One big store or several different stores?
Should child components (RoomTemperatureManagers) have their own state or receive props from store?
Ad 1. One big store is easier, as long as it does not get to complicated. Rule of thumb that I use: if your store has > 300 lines of code, probably better to separate in different stores.
Ad 2. Props are generally better than state. But in your case, I would think you will need state in e.g. your Temperature-manager: you set the temperature in your app (and want to see that reflected in some slider or whatever). For this, you will need state.
State updates the front-end immediately (optimistic update).
The component then sends of a set_temparature action to a sensor in the
house.
Then the sensor in the house confirms that it has set the new
temperature to your app.
The store(s) update(s) and emit change.
The temperature setting from the sensor in the house is communicated as
props to your Temperature manager.
The Temperature manager does whatever it needs to do (simply update state with new prop, display confirmation message, or nice error message if things broke down along the communication chain).
I believe the best approach would be to delegate. Your TemperatureManager should have a mechanism to notify listeners that there is an update and in turn, the Room(Temperature|System)Manager would send as a listener a callback that would consume the updated data and change the state accordingly. This will leverage the virtual DOM diff so only changes will be displayed and not whole parts re-rendered as well as create a single point that would communicate with the Store. Room(Temperature|System)Manager should only communicate with the Store if there is an update it needs to do to the model it is working with.
TemperatureManager could be improved if on subscribing, you can specify which data to listen to for updates. It should not assume that a particular 'manager' should get any subset of data.

using GPS sensor on ultrabook

I am developing a WPF application on an Intel Ultrabook. As the Ultrabook already includes GPS sensors, how can I go about retrieving my current location inside my app using this sensor?
I am not able to find any sample code to get me started. Any guidance is appreciated.
See:
http://msdn.microsoft.com/en-us/library/system.device.location.geocoordinatewatcher(v=vs.100).aspx
especially the statement:
To begin accessing location data, create a GeoCoordinateWatcher and call Start or TryStart to initiate the acquisition of data from the current location provider.
The Status property can be checked to determine if data is available. If data is available, you can get the location one time from the Position property, or receive continuous location updates by handling the PositionChanged event.

Resources