Browse Source

Added remove props handler

master
Anthony Hinsinger 5 years ago
parent
commit
3be69bcf4c
  1. 18
      index.js

18
index.js

@ -36,6 +36,11 @@ const typeDefs = gql` @@ -36,6 +36,11 @@ const typeDefs = gql`
permission: Int
}
type RemovedProperty {
id: String!
device: String!
}
interface Vector {
id: String!
name: String!
@ -127,6 +132,10 @@ const typeDefs = gql` @@ -127,6 +132,10 @@ const typeDefs = gql`
connected: Boolean
}
type RemovedDevice {
id: String!
}
type Message {
id: String
device: Device!
@ -180,6 +189,7 @@ const typeDefs = gql` @@ -180,6 +189,7 @@ const typeDefs = gql`
disconnected: Int
newDevice: Device
newProperty: Property
removeProperty: RemovedProperty
newValue: Vector
newMessage: Message
}
@ -210,6 +220,7 @@ indi @@ -210,6 +220,7 @@ indi
pubsub.publish(["NEW_DEVICE"], { newDevice: device });
})
.on("newProperty", (property) => {
console.log("new props");
if (
property.getType() === Indi.PropertyType.Number ||
property.getType() === Indi.PropertyType.Switch ||
@ -219,6 +230,10 @@ indi @@ -219,6 +230,10 @@ indi
pubsub.publish(["NEW_PROPERTY"], { newProperty: property });
}
})
.on("removeProperty", (propname, devname) => {
console.log("remove props");
pubsub.publish(["REMOVE_PROPERTY"], { removeProperty: { id: propname, device: devname } });
})
.on("newNumber", (n) => {
pubsub.publish(["NEW_VALUE"], { newValue: n });
})
@ -342,6 +357,9 @@ const resolvers = { @@ -342,6 +357,9 @@ const resolvers = {
newProperty: {
subscribe: () => pubsub.asyncIterator(["NEW_PROPERTY"]),
},
removeProperty: {
subscribe: () => pubsub.asyncIterator(["REMOVE_PROPERTY"]),
},
newValue: {
subscribe: () => pubsub.asyncIterator(["NEW_VALUE"]),
},

Loading…
Cancel
Save